eric-maynard commented on code in PR #1231:
URL: https://github.com/apache/polaris/pull/1231#discussion_r2010656785


##########
quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/GenericTableCatalogTest.java:
##########
@@ -306,4 +336,166 @@ public void testGenericTableRoundTrip() {
     
Assertions.assertThat(resultEntity.getPropertiesAsMap()).isEqualTo(properties);
     Assertions.assertThat(resultEntity.getName()).isEqualTo(tableName);
   }
+
+  @Test
+  public void testLoadNonExistentTable() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    Assertions.assertThatCode(
+            () -> 
genericTableCatalog.loadGenericTable(TableIdentifier.of("ns", "t1")))
+        .hasMessageContaining("does not exist: ns.t1");
+  }
+
+  @Test
+  public void testReadIcebergTableAsGeneric() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    String tableName = "t1";
+
+    icebergCatalog.createTable(TableIdentifier.of("ns", tableName), SCHEMA);
+    Assertions.assertThatCode(
+            () -> 
genericTableCatalog.loadGenericTable(TableIdentifier.of("ns", tableName)))
+        .hasMessageContaining("does not exist: ns.t1");
+  }
+
+  @Test
+  public void testReadIcebergViewAsGeneric() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    String tableName = "t1";
+
+    icebergCatalog.buildView(TableIdentifier.of("ns", tableName));
+    Assertions.assertThatCode(
+            () -> 
genericTableCatalog.loadGenericTable(TableIdentifier.of("ns", tableName)))
+        .hasMessageContaining("does not exist: ns.t1");
+  }
+
+  @Test
+  public void testReadGenericAsIcebergTable() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    String tableName = "t1";
+
+    genericTableCatalog.createGenericTable(TableIdentifier.of("ns", 
tableName), "format", Map.of());
+    Assertions.assertThatCode(() -> 
icebergCatalog.loadTable(TableIdentifier.of("ns", tableName)))
+        .hasMessageContaining("does not exist: ns.t1");
+  }
+
+  @Test
+  public void testReadGenericAsIcebergView() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    String tableName = "t1";
+
+    genericTableCatalog.createGenericTable(TableIdentifier.of("ns", 
tableName), "format", Map.of());
+    Assertions.assertThatCode(() -> 
icebergCatalog.loadView(TableIdentifier.of("ns", tableName)))
+        .hasMessageContaining("does not exist: ns.t1");
+  }
+
+  @Test
+  public void testListTables() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    for (int i = 0; i < 10; i++) {
+      genericTableCatalog.createGenericTable(TableIdentifier.of("ns", "t" + 
i), "format", Map.of());
+    }
+
+    List<TableIdentifier> listResult = 
genericTableCatalog.listGenericTables(namespace);
+
+    Assertions.assertThat(listResult.size()).isEqualTo(10);
+    
Assertions.assertThat(listResult.stream().map(TableIdentifier::toString).toList())
+        
.isEqualTo(listResult.stream().map(TableIdentifier::toString).sorted().toList());
+
+    Assertions.assertThat(icebergCatalog.listTables(namespace)).isEmpty();
+  }
+
+  @Test
+  public void testListTablesEmpty() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    for (int i = 0; i < 10; i++) {
+      icebergCatalog.createTable(TableIdentifier.of("ns", "t" + i), SCHEMA);
+    }
+
+    
Assertions.assertThat(icebergCatalog.listTables(namespace).size()).isEqualTo(10);
+    
Assertions.assertThat(genericTableCatalog.listGenericTables(namespace)).isEmpty();
+  }
+
+  @Test
+  public void testListIcebergTables() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    for (int i = 0; i < 10; i++) {
+      icebergCatalog.createTable(TableIdentifier.of("ns", "t" + i), SCHEMA);
+    }
+
+    List<TableIdentifier> listResult = icebergCatalog.listTables(namespace);
+
+    Assertions.assertThat(listResult.size()).isEqualTo(10);
+    
Assertions.assertThat(listResult.stream().map(TableIdentifier::toString).toList())
+        
.isEqualTo(listResult.stream().map(TableIdentifier::toString).sorted().toList());
+
+    
Assertions.assertThat(genericTableCatalog.listGenericTables(namespace)).isEmpty();
+  }
+
+  @Test
+  public void testDropNonExistentTable() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    Assertions.assertThatCode(
+            () -> 
genericTableCatalog.dropGenericTable(TableIdentifier.of("ns", "t1")))
+        .hasMessageContaining("Table does not exist: ns.t1");
+  }
+
+  @Test
+  public void testDropNonExistentNamespace() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+
+    Assertions.assertThatCode(
+            () -> 
genericTableCatalog.dropGenericTable(TableIdentifier.of("ns2", "t1")))
+        .hasMessageContaining("Table does not exist: ns2.t1");
+  }
+
+  @Test
+  public void testDropIcebergTable() {
+    Namespace namespace = Namespace.of("ns");
+    icebergCatalog.createNamespace(namespace);
+    icebergCatalog.createTable(TableIdentifier.of("ns", "t1"), SCHEMA);
+
+    Assertions.assertThatCode(
+            () -> 
genericTableCatalog.dropGenericTable(TableIdentifier.of("ns", "t1")))
+        .hasMessageContaining("Table does not exist: ns.t1");

Review Comment:
   `testDropViaIceberg` asserts this



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to