the-other-tim-brown commented on code in PR #648:
URL: https://github.com/apache/incubator-xtable/pull/648#discussion_r1958927295


##########
xtable-hive-metastore/src/test/java/org/apache/xtable/hms/TestHMSCatalogSyncClient.java:
##########
@@ -72,7 +76,8 @@ private HMSCatalogSyncClient createHMSCatalogSyncClient() {
         mockHMSCatalogConfig,
         testConfiguration,
         mockMetaStoreClient,
-        mockTableBuilder);
+        mockTableBuilder,
+        Optional.of(partitionSyncTool));

Review Comment:
   Can you have a case where this is empty as well to show that it does not 
cause issues?



##########
xtable-core/src/main/java/org/apache/xtable/hudi/catalog/HudiCatalogTablePropertiesExtractor.java:
##########
@@ -33,15 +33,21 @@
 import org.apache.xtable.schema.SparkSchemaExtractor;
 
 /** Util class to fetch details about Hudi table */
-public class HudiCatalogTableUtils {
+public class HudiCatalogTablePropertiesExtractor {

Review Comment:
   Use lombok to make a private no-args constructor



##########
xtable-hive-metastore/src/test/java/org/apache/xtable/hms/TestHMSCatalogPartitionSyncOperations.java:
##########
@@ -0,0 +1,490 @@
+/*
+ * 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.xtable.hms;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import lombok.SneakyThrows;
+
+import org.apache.hadoop.hive.metastore.api.SerDeInfo;
+import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.thrift.TException;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import org.apache.xtable.catalog.CatalogPartition;
+import org.apache.xtable.catalog.CatalogPartitionSyncOperations;
+import org.apache.xtable.exception.CatalogSyncException;
+
+@ExtendWith(MockitoExtension.class)
+public class TestHMSCatalogPartitionSyncOperations extends 
HMSCatalogSyncTestBase {
+
+  private CatalogPartitionSyncOperations mockHMSPartitionSyncOperations;
+
+  void setupCommonMocks() {
+    mockHMSPartitionSyncOperations =

Review Comment:
   I still find the naming confusing here, why do we call the actual instance 
the mock here?



##########
xtable-hive-metastore/src/test/java/org/apache/xtable/hms/TestHMSCatalogPartitionSyncOperations.java:
##########
@@ -0,0 +1,472 @@
+/*
+ * 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.xtable.hms;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import lombok.SneakyThrows;
+
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.SerDeInfo;
+import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.thrift.TException;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import org.apache.xtable.catalog.CatalogPartition;
+import org.apache.xtable.catalog.CatalogPartitionSyncOperations;
+import org.apache.xtable.exception.CatalogSyncException;
+
+@ExtendWith(MockitoExtension.class)
+public class TestHMSCatalogPartitionSyncOperations extends 
HMSCatalogSyncTestBase {
+
+  private CatalogPartitionSyncOperations mockHMSPartitionSyncOperations;
+
+  void setupCommonMocks() {
+    mockHMSPartitionSyncOperations =
+        new HMSCatalogPartitionSyncOperations(mockMetaStoreClient, 
mockHMSCatalogConfig);
+  }
+
+  @SneakyThrows
+  @Test
+  void testGetAllPartitions() {
+    setupCommonMocks();
+
+    Partition hivePartition1 = new Partition();
+    hivePartition1.setValues(Collections.singletonList("value1"));
+    StorageDescriptor sd1 = new StorageDescriptor();
+    sd1.setLocation("location1");
+    hivePartition1.setSd(sd1);
+
+    Partition hivePartition2 = new Partition();
+    hivePartition2.setValues(Collections.singletonList("value2"));
+    StorageDescriptor sd2 = new StorageDescriptor();
+    sd2.setLocation("location2");
+    hivePartition2.setSd(sd2);
+
+    List<Partition> hivePartitions = Arrays.asList(hivePartition1, 
hivePartition2);
+    when(mockMetaStoreClient.listPartitions(
+            TEST_CATALOG_TABLE_IDENTIFIER.getDatabaseName(),
+            TEST_CATALOG_TABLE_IDENTIFIER.getTableName(),
+            (short) -1))
+        .thenReturn(hivePartitions);
+    List<CatalogPartition> partitions =
+        
mockHMSPartitionSyncOperations.getAllPartitions(TEST_CATALOG_TABLE_IDENTIFIER);
+
+    assertEquals(2, partitions.size());
+    assertEquals("location1", partitions.get(0).getStorageLocation());
+    assertEquals(1, partitions.get(0).getValues().size());
+    assertEquals("value1", partitions.get(0).getValues().get(0));
+    assertEquals("location2", partitions.get(1).getStorageLocation());
+    assertEquals(1, partitions.get(1).getValues().size());
+    assertEquals("value2", partitions.get(1).getValues().get(0));
+
+    verify(mockMetaStoreClient, times(1))
+        .listPartitions(
+            TEST_CATALOG_TABLE_IDENTIFIER.getDatabaseName(),
+            TEST_CATALOG_TABLE_IDENTIFIER.getTableName(),
+            (short) -1);
+  }
+
+  @Test
+  void testAddPartitionsToTableSuccess() throws Exception {
+    setupCommonMocks();
+    when(mockHMSCatalogConfig.getMaxPartitionsPerRequest()).thenReturn(100);
+    CatalogPartition partition1 =
+        new CatalogPartition(Collections.singletonList("value1"), "location1");
+    CatalogPartition partition2 =
+        new CatalogPartition(Collections.singletonList("value2"), "location2");
+    List<CatalogPartition> partitionsToAdd = Arrays.asList(partition1, 
partition2);
+
+    StorageDescriptor tableSd = new StorageDescriptor();
+    tableSd.setCols(Collections.emptyList());
+    tableSd.setInputFormat("inputFormat");
+    tableSd.setOutputFormat("outputFormat");
+    tableSd.setSerdeInfo(new SerDeInfo());
+
+    org.apache.hadoop.hive.metastore.api.Table table =

Review Comment:
   Can you use an import for 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