afedulov commented on code in PR #19660:
URL: https://github.com/apache/flink/pull/19660#discussion_r870633549


##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDeserializeExceptionTest.java:
##########
@@ -41,7 +41,7 @@
 import java.util.Collections;
 import java.util.Properties;
 
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.fail;

Review Comment:
   assertThrownBy



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectITCase.java:
##########
@@ -723,55 +710,55 @@ public void testShowPartitions() throws Exception {
                 "alter table tbl add partition 
(dt='2020-04-30',country='china') partition (dt='2020-04-30',country='us')");
 
         ObjectPath tablePath = new ObjectPath("default", "tbl");
-        assertEquals(2, hiveCatalog.listPartitions(tablePath).size());
+        assertThat(hiveCatalog.listPartitions(tablePath)).hasSize(2);
 
         List<Row> partitions =
                 CollectionUtil.iteratorToList(tableEnv.executeSql("show 
partitions tbl").collect());
-        assertEquals(2, partitions.size());
-        
assertTrue(partitions.toString().contains("dt=2020-04-30/country=china"));
-        assertTrue(partitions.toString().contains("dt=2020-04-30/country=us"));
+        assertThat(partitions).hasSize(2);
+        
assertThat(partitions.toString()).contains("dt=2020-04-30/country=china");
+        assertThat(partitions.toString()).contains("dt=2020-04-30/country=us");
         partitions =
                 CollectionUtil.iteratorToList(
                         tableEnv.executeSql("show partitions tbl partition 
(dt='2020-04-30')")
                                 .collect());
-        assertEquals(2, partitions.size());
-        
assertTrue(partitions.toString().contains("dt=2020-04-30/country=china"));
-        assertTrue(partitions.toString().contains("dt=2020-04-30/country=us"));
+        assertThat(partitions).hasSize(2);
+        
assertThat(partitions.toString()).contains("dt=2020-04-30/country=china");
+        assertThat(partitions.toString()).contains("dt=2020-04-30/country=us");
         partitions =
                 CollectionUtil.iteratorToList(
                         tableEnv.executeSql("show partitions tbl partition 
(country='china')")
                                 .collect());
-        assertEquals(1, partitions.size());
-        
assertTrue(partitions.toString().contains("dt=2020-04-30/country=china"));
+        assertThat(partitions).hasSize(1);
+        
assertThat(partitions.toString()).contains("dt=2020-04-30/country=china");
         partitions =
                 CollectionUtil.iteratorToList(
                         tableEnv.executeSql(
                                         "show partitions tbl partition 
(dt='2020-04-30',country='china')")
                                 .collect());
-        assertEquals(1, partitions.size());
-        
assertTrue(partitions.toString().contains("dt=2020-04-30/country=china"));
+        assertThat(partitions).hasSize(1);
+        
assertThat(partitions.toString()).contains("dt=2020-04-30/country=china");
         partitions =
                 CollectionUtil.iteratorToList(
                         tableEnv.executeSql(
                                         "show partitions tbl partition 
(dt='2020-05-01',country='japan')")
                                 .collect());
-        assertEquals(0, partitions.size());
+        assertThat(partitions).isEmpty();
         try {
             CollectionUtil.iteratorToList(
                     tableEnv.executeSql(
                                     "show partitions tbl partition 
(de='2020-04-30',city='china')")
                             .collect());
         } catch (TableException e) {
-            assertEquals(
-                    String.format(
-                            "Could not execute SHOW PARTITIONS %s.%s PARTITION 
(de=2020-04-30, city=china)",
-                            hiveCatalog.getName(), tablePath),
-                    e.getMessage());
+            assertThat(e)

Review Comment:
   assertThatThrownBy



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDynamicTableFactoryTest.java:
##########
@@ -98,16 +94,16 @@ public void testHiveStreamingSourceOptions() throws 
Exception {
                                 + " tblproperties ('%s' = 'true', '%s' = 
'latest')",
                         STREAMING_SOURCE_ENABLE.key(), 
STREAMING_SOURCE_PARTITION_INCLUDE.key()));
         DynamicTableSource tableSource2 = getTableSource("table2");
-        assertTrue(tableSource2 instanceof HiveLookupTableSource);
+        assertThat(tableSource2).isInstanceOf(HiveLookupTableSource.class);
         try {
             tableEnv.executeSql("select * from table2");
         } catch (Throwable t) {
-            assertTrue(
-                    ExceptionUtils.findThrowableWithMessage(
+            assertThat(

Review Comment:
   assertThatThrownBy



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/table/functions/hive/HiveGenericUDFTest.java:
##########
@@ -255,8 +256,8 @@ public void testMap() {
 
         Object[] result = (Object[]) udf2.eval(udf.eval(testInput));
 
-        assertEquals(3, result.length);
-        assertThat(Arrays.asList(result), containsInAnyOrder("1", "2", "3"));
+        assertThat(result).hasSize(3);
+        
assertThat(Arrays.asList(result)).satisfies(matching(containsInAnyOrder("1", 
"2", "3")));

Review Comment:
   
https://joel-costigliola.github.io/assertj/core/api/org/assertj/core/api/ListAssert.html#contains(ELEMENT...)



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDynamicTableFactoryTest.java:
##########
@@ -233,12 +229,12 @@ public void testInvalidOptions() throws Exception {
         try {
             getTableSource("table9");
         } catch (Throwable t) {
-            assertTrue(
-                    ExceptionUtils.findThrowableWithMessage(
+            assertThat(

Review Comment:
   assertThatThrownBy



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectITCase.java:
##########
@@ -835,9 +822,9 @@ private void verifyUnsupportedOperation(String ddl) {
             fail("We don't support " + ddl);
         } catch (ValidationException e) {
             // expected
-            assertTrue(
-                    "Expect UnsupportedOperationException for " + ddl,
-                    e.getCause() instanceof UnsupportedOperationException);
+            assertThat(e.getCause())

Review Comment:
   assertThatThrownBy



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveTableSinkITCase.java:
##########
@@ -437,12 +431,12 @@ public void testCustomPartitionCommitPolicyNotFound() {
             
testStreamingWriteWithCustomPartitionCommitPolicy(customCommitPolicyClassName);
             fail("ExecutionException expected");
         } catch (Exception e) {
-            assertTrue(
-                    ExceptionUtils.findThrowableWithMessage(
+            assertThat(

Review Comment:
   assertThatThrownBy



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveRunnerITCase.java:
##########
@@ -578,13 +581,13 @@ private void testTransactionalTable(boolean batch) {
             } catch (Exception e) {
                 exceptions.add(e);
             }
-            assertEquals(2, exceptions.size());
+            assertThat(exceptions).hasSize(2);

Review Comment:
   It looks a bit awkward to do that only for two exceptions. Maybe split into 
individual assertThatThrownBy checks?



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