szehon-ho commented on code in PR #6591:
URL: https://github.com/apache/iceberg/pull/6591#discussion_r1086134224


##########
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java:
##########
@@ -1176,4 +1178,37 @@ public void 
testDatabaseLocationWithSlashInWarehouseDir() {
 
     Assert.assertEquals("s3://bucket/database.db", database.getLocationUri());
   }
+
+  @Test
+  public void testRegisterTable() {
+    TableIdentifier identifier = TableIdentifier.of(DB_NAME, "t1");
+    catalog.createTable(identifier, getTestSchema());
+    Table registeringTable = catalog.loadTable(identifier);
+    catalog.dropTable(identifier, false);
+    TableOperations ops = ((HasTableOperations) registeringTable).operations();
+    String metadataLocation = ((HiveTableOperations) 
ops).currentMetadataLocation();
+    Table registeredTable = catalog.registerTable(identifier, 
metadataLocation);
+    org.assertj.core.api.Assertions.assertThat(registeredTable).isNotNull();
+    TestHelpers.assertSerializedAndLoadedMetadata(registeringTable, 
registeredTable);
+    String expectedMetadataLocation =
+        ((HasTableOperations) 
registeredTable).operations().current().metadataFileLocation();
+    org.assertj.core.api.Assertions.assertThat(metadataLocation)
+        .isEqualTo(expectedMetadataLocation);
+    
org.assertj.core.api.Assertions.assertThat(catalog.loadTable(identifier)).isNotNull();
+    
org.assertj.core.api.Assertions.assertThat(catalog.dropTable(identifier)).isTrue();
+  }
+
+  @Test
+  public void testRegisterExistingTable() {
+    TableIdentifier identifier = TableIdentifier.of(DB_NAME, "t1");
+    catalog.createTable(identifier, getTestSchema());
+    Table registeringTable = catalog.loadTable(identifier);
+    TableOperations ops = ((HasTableOperations) registeringTable).operations();
+    String metadataLocation = ((HiveTableOperations) 
ops).currentMetadataLocation();
+    org.assertj.core.api.Assertions.assertThatThrownBy(
+            () -> catalog.registerTable(identifier, metadataLocation))
+        .isInstanceOf(AlreadyExistsException.class)
+        .hasMessage("Table already exists: hivedb.t1");
+    org.assertj.core.api.Assertions.assertThat(catalog.dropTable(identifier, 
true)).isTrue();

Review Comment:
   I guess alternatively, we could keep this ugly class reference, but we need 
to make sure to make a follow up PR to clean up the rest of TestHiveCatalog's 
assertions to use "org.assertj.core.api.Assertion"?



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