nastra commented on code in PR #14113:
URL: https://github.com/apache/iceberg/pull/14113#discussion_r2364025070


##########
bigquery/src/test/java/org/apache/iceberg/gcp/bigquery/TestBigQueryCatalog.java:
##########
@@ -144,9 +154,61 @@ public void createTableTransaction(int formatVersion) {
   @Test
   public void testCreateTableWithDefaultColumnValue() {}
 
-  @Disabled("BigQuery Metastore does not support multi layer namespaces")
   @Test
-  public void testLoadMetadataTable() {}
+  public void testLoadMetadataTable() {
+
+    // Create a spy of the catalog to verify method calls
+    BigQueryMetastoreCatalog spyCatalog = spy(catalog);
+
+    // Create mock objects
+    TableOperations mockOps = Mockito.mock(TableOperations.class);
+    TableMetadata mockMetadata = Mockito.mock(TableMetadata.class);
+    Table mockMetadataTable = Mockito.mock(Table.class);
+
+    // Mock the table operations to return metadata (indicating base table 
exists)
+    when(mockOps.current()).thenReturn(mockMetadata);
+
+    // Create the expected base table identifier that will be extracted from 
the metadata table
+    // identifier
+    TableIdentifier expectedBaseTableId = TableIdentifier.of("dataset1", 
"table1");
+    when(spyCatalog.newTableOps(expectedBaseTableId)).thenReturn(mockOps);
+
+    // Use MockedStatic to mock the static 
MetadataTableUtils.createMetadataTableInstance call
+    try (MockedStatic<MetadataTableUtils> mockedUtils =
+        Mockito.mockStatic(MetadataTableUtils.class)) {
+      mockedUtils
+          .when(
+              () ->
+                  MetadataTableUtils.createMetadataTableInstance(
+                      any(TableOperations.class),
+                      any(String.class),
+                      any(TableIdentifier.class),
+                      any(TableIdentifier.class),
+                      any()))
+          .thenReturn(mockMetadataTable);
+
+      // Create a metadata table identifier
+      TableIdentifier metadataTableId =
+          TableIdentifier.of(Namespace.of("dataset1", "table1"), "partitions");
+
+      // Call loadTable which should trigger the metadata table loading path
+      Table result = spyCatalog.loadTable(metadataTableId);
+
+      // Verify that MetadataTableUtils.createMetadataTableInstance was called
+      // This confirms that loadMetadataTable path was taken
+      mockedUtils.verify(
+          () ->
+              MetadataTableUtils.createMetadataTableInstance(
+                  any(TableOperations.class),
+                  any(String.class),
+                  any(TableIdentifier.class),
+                  any(TableIdentifier.class),
+                  any()));
+
+      // Verify the result is the mocked metadata table
+      assertThat(result).isSameAs(mockMetadataTable);
+    }
+  }

Review Comment:
   ```suggestion
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to