rdblue commented on a change in pull request #1633:
URL: https://github.com/apache/iceberg/pull/1633#discussion_r521622919



##########
File path: 
aws/src/integration/java/org/apache/iceberg/aws/glue/GlueCatalogTableTest.java
##########
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.aws.glue;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Optional;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.BaseMetastoreTableOperations;
+import org.apache.iceberg.DataFile;
+import org.apache.iceberg.DataFiles;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.TableMetadata;
+import org.apache.iceberg.TableOperations;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.exceptions.AlreadyExistsException;
+import org.apache.iceberg.exceptions.NoSuchTableException;
+import org.apache.iceberg.types.Types;
+import org.junit.Assert;
+import org.junit.Test;
+import software.amazon.awssdk.services.glue.model.GetTableRequest;
+import software.amazon.awssdk.services.glue.model.GetTableResponse;
+import software.amazon.awssdk.services.glue.model.GetTableVersionsRequest;
+import software.amazon.awssdk.services.s3.model.HeadObjectRequest;
+import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
+import software.amazon.awssdk.services.s3.model.ListObjectsV2Response;
+import software.amazon.awssdk.services.s3.model.S3Object;
+
+public class GlueCatalogTableTest extends GlueTestBase {
+
+  @Test
+  public void testCreateTable() {
+    String namespace = createNamespace();
+    String tableName = getRandomName();
+    glueCatalog.createTable(TableIdentifier.of(namespace, tableName), schema, 
partitionSpec);
+    GetTableResponse response = glue.getTable(GetTableRequest.builder()
+        .databaseName(namespace).name(tableName).build());
+    Assert.assertEquals(namespace, response.table().databaseName());
+    Assert.assertEquals(tableName, response.table().name());
+    
Assert.assertEquals(BaseMetastoreTableOperations.ICEBERG_TABLE_TYPE_VALUE.toUpperCase(Locale.ENGLISH),
+        
response.table().parameters().get(BaseMetastoreTableOperations.TABLE_TYPE_PROP));
+    
Assert.assertTrue(response.table().parameters().containsKey(BaseMetastoreTableOperations.METADATA_LOCATION_PROP));
+    String metaLocation = 
response.table().parameters().get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP);
+    String key = metaLocation.split(testBucketName, -1)[1].substring(1);
+    
s3.headObject(HeadObjectRequest.builder().bucket(testBucketName).key(key).build());
+    Table table = glueCatalog.loadTable(TableIdentifier.of(namespace, 
tableName));
+    Assert.assertEquals(partitionSpec, table.spec());
+    Assert.assertEquals(schema.toString(), table.schema().toString());
+  }
+
+  @Test
+  public void testCreateTableDuplicate() {
+    String namespace = createNamespace();
+    String tableName = createTable(namespace);
+    AssertHelpers.assertThrows("should not create table with the same name",
+        AlreadyExistsException.class,
+        () -> glueCatalog.createTable(TableIdentifier.of(namespace, 
tableName), schema, partitionSpec));
+  }
+
+  @Test
+  public void testCreateTableBadName() {
+    String namespace = createNamespace();
+    AssertHelpers.assertThrows("should not create table with bad name",
+        IllegalArgumentException.class,
+        () -> glueCatalog.createTable(TableIdentifier.of(namespace, 
"table-1"), schema, partitionSpec));
+  }
+
+  @Test
+  public void testListTables() {
+    String namespace = createNamespace();
+    // list table should have nothing

Review comment:
       This context is usually better if it is added to the assertion, so that 
when the test fails it is printed in the output.




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

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