gh-yzou commented on code in PR #1231:
URL: https://github.com/apache/polaris/pull/1231#discussion_r2013049332


##########
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:
   sorry, that is not what i mean here. so i believe I left that comment for 
this test point 
   ```
    @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("Generic table does not exist: ns.t1");
     }
   ```
   so this test is creating an iceberg table, and then testing we can not drop 
the iceberg table through dropGenericTable API. I was just suggesting to add 
one more testing line after 
   ```
   Assertions.assertThatCode(
               () -> 
genericTableCatalog.dropGenericTable(TableIdentifier.of("ns", "t1")))
           .hasMessageContaining("Generic table does not exist: ns.t1");
   ```
   to call icebergCatalog.dropTable and it could be successful, so that the 
test is clear that the table has been created successfully, but can not be 
dropped using dropGenericTable. 
   
   Again, that is a nit suggestion. The current test also looks fine to me



-- 
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