wangzzu commented on code in PR #23233:
URL: https://github.com/apache/flink/pull/23233#discussion_r1299771667


##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/CoGroupTaskTest.java:
##########
@@ -34,11 +34,14 @@
 import org.apache.flink.types.Value;
 import org.apache.flink.util.Collector;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.TestTemplate;
 
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.fail;
+
 public class CoGroupTaskTest extends DriverTestBase<CoGroupFunction<Record, 
Record, Record>> {

Review Comment:
   Make test classes package-visible. Others are similar, you can check it 
globally



##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/CoGroupTaskTest.java:
##########
@@ -268,19 +281,13 @@ public void testFailingSortCoGroupTask() {
         final CoGroupDriver<Record, Record, Record> testTask =
                 new CoGroupDriver<Record, Record, Record>();
 
-        try {
-            testDriver(testTask, MockFailingCoGroupStub.class);
-            Assert.fail("Function exception was not forwarded.");
-        } catch (ExpectedTestException etex) {
-            // good!
-        } catch (Exception e) {
-            e.printStackTrace();
-            Assert.fail("The test caused an exception.");
-        }
+        assertThatThrownBy(() -> testDriver(testTask, 
MockFailingCoGroupStub.class))
+                .withFailMessage("Function exception was not forwarded.")

Review Comment:
   the msg should remove



##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/drivers/ReduceDriverTest.java:
##########
@@ -74,16 +76,16 @@ public void testReduceDriverImmutableEmpty() {
             driver.prepare();
             driver.run();
 
-            Assert.assertEquals(0, result.getList().size());
+            assertThat(result.getList()).hasSize(0);

Review Comment:
   `.isEmpty();` like above



##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/CombineTaskTest.java:
##########
@@ -130,20 +132,17 @@ public void testFailingCombineTask() {
             final GroupReduceCombineDriver<Tuple2<Integer, Integer>, 
Tuple2<Integer, Integer>>
                     testTask = new GroupReduceCombineDriver<>();
 
-            try {
-                testDriver(testTask, MockFailingCombiningReduceStub.class);
-                fail("Exception not forwarded.");
-            } catch (ExpectedTestException etex) {
-                // good!
-            }
+            assertThatThrownBy(() -> testDriver(testTask, 
MockFailingCombiningReduceStub.class))
+                    .withFailMessage("Exception not forwarded.")

Review Comment:
   same as above



##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/CoGroupTaskExternalITCase.java:
##########
@@ -30,8 +30,10 @@
 import org.apache.flink.types.Value;
 import org.apache.flink.util.Collector;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.TestTemplate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
 
 public class CoGroupTaskExternalITCase

Review Comment:
   Make test classes package-visible



##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/DataSourceTaskTest.java:
##########
@@ -116,32 +115,28 @@ public void testDataSourceTask() throws IOException {
             keyValueCountMap.get(key).add(val);
         }
 
-        Assert.assertTrue(
-                "Invalid key count in out file. Expected: "
-                        + keyCnt
-                        + " Actual: "
-                        + keyValueCountMap.keySet().size(),
-                keyValueCountMap.keySet().size() == keyCnt);
+        assertThat(keyValueCountMap)
+                .withFailMessage(
+                        "Invalid key count in out file. Expected: %d, Actual: 
%d",
+                        keyCnt, keyValueCountMap.size())
+                .hasSize(keyCnt);
 
         for (Integer mapKey : keyValueCountMap.keySet()) {
-            Assert.assertTrue(
-                    "Invalid value count for key: "
-                            + mapKey
-                            + ". Expected: "
-                            + valCnt
-                            + " Actual: "
-                            + keyValueCountMap.get(mapKey).size(),
-                    keyValueCountMap.get(mapKey).size() == valCnt);
+            assertThat(keyValueCountMap.get(mapKey))
+                    .withFailMessage(
+                            "Invalid value count for key: %d. Expected: %d, 
Actual: %d",
+                            mapKey, valCnt, 
keyValueCountMap.get(mapKey).size())

Review Comment:
   this msg can remove too, junit test can throw similar exception information



-- 
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...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to