1996fanrui commented on code in PR #23960:
URL: https://github.com/apache/flink/pull/23960#discussion_r1498532976


##########
flink-core/src/test/java/org/apache/flink/api/common/state/StateDescriptorTest.java:
##########
@@ -247,22 +239,21 @@ public void go() {
         for (CheckedThread t : threads) {
             t.sync();
         }
-        assertEquals(
-                "Should use only one serializer but actually: " + serializers,
-                1,
-                serializers.size());
+        assertThat(serializers.size())

Review Comment:
   hasSize directly?



##########
flink-core/src/test/java/org/apache/flink/api/common/typeutils/CompositeTypeSerializerUtilTest.java:
##########
@@ -23,22 +23,23 @@
 import 
org.apache.flink.testutils.migration.SchemaCompatibilityTestingSerializer;
 import 
org.apache.flink.testutils.migration.SchemaCompatibilityTestingSerializer.SchemaCompatibilityTestingSnapshot;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.util.Arrays;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertArrayEquals;

Review Comment:
   Could `import static org.junit.Assert.assertArrayEquals;` be replace with 
`org.assertj.core.api.Assertions.assertThat`?



##########
flink-core/src/test/java/org/apache/flink/api/common/io/RichInputFormatTest.java:
##########
@@ -21,37 +21,35 @@
 import org.apache.flink.api.common.ExecutionConfig;
 import org.apache.flink.api.common.TaskInfo;
 import org.apache.flink.api.common.TaskInfoImpl;
-import org.apache.flink.api.common.accumulators.Accumulator;
 import org.apache.flink.api.common.functions.util.RuntimeUDFContext;
-import org.apache.flink.core.fs.Path;
 import org.apache.flink.metrics.groups.UnregisteredMetricsGroup;
 import org.apache.flink.types.Value;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.util.HashMap;
-import java.util.concurrent.Future;
 
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests runtime context access from inside an RichInputFormat class. */
-public class RichInputFormatTest {
+class RichInputFormatTest {
 
     @Test
-    public void testCheckRuntimeContextAccess() {
-        final SerializedInputFormat<Value> inputFormat = new 
SerializedInputFormat<Value>();
+    void testCheckRuntimeContextAccess() {
+        final SerializedInputFormat<Value> inputFormat = new 
SerializedInputFormat<>();
         final TaskInfo taskInfo = new TaskInfoImpl("test name", 3, 1, 3, 0);
         inputFormat.setRuntimeContext(
                 new RuntimeUDFContext(
                         taskInfo,
                         getClass().getClassLoader(),
                         new ExecutionConfig(),
-                        new HashMap<String, Future<Path>>(),
-                        new HashMap<String, Accumulator<?, ?>>(),
+                        new HashMap<>(),
+                        new HashMap<>(),
                         UnregisteredMetricsGroup.createOperatorMetricGroup()));
 
-        
assertEquals(inputFormat.getRuntimeContext().getTaskInfo().getIndexOfThisSubtask(),
 1);
-        assertEquals(
-                
inputFormat.getRuntimeContext().getTaskInfo().getNumberOfParallelSubtasks(), 3);
+        
assertThat(inputFormat.getRuntimeContext().getTaskInfo().getIndexOfThisSubtask())
+                .isEqualTo(1);

Review Comment:
   ```suggestion
                   .isOne();
   ```



##########
flink-core/src/test/java/org/apache/flink/api/common/io/RichOutputFormatTest.java:
##########
@@ -21,38 +21,36 @@
 import org.apache.flink.api.common.ExecutionConfig;
 import org.apache.flink.api.common.TaskInfo;
 import org.apache.flink.api.common.TaskInfoImpl;
-import org.apache.flink.api.common.accumulators.Accumulator;
 import org.apache.flink.api.common.functions.util.RuntimeUDFContext;
-import org.apache.flink.core.fs.Path;
 import org.apache.flink.metrics.groups.UnregisteredMetricsGroup;
 import org.apache.flink.types.Value;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.util.HashMap;
-import java.util.concurrent.Future;
 
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests runtime context access from inside an RichOutputFormat class. */
-public class RichOutputFormatTest {
+class RichOutputFormatTest {
 
     @Test
-    public void testCheckRuntimeContextAccess() {
-        final SerializedOutputFormat<Value> inputFormat = new 
SerializedOutputFormat<Value>();
+    void testCheckRuntimeContextAccess() {
+        final SerializedOutputFormat<Value> inputFormat = new 
SerializedOutputFormat<>();
         final TaskInfo taskInfo = new TaskInfoImpl("test name", 3, 1, 3, 0);
 
         inputFormat.setRuntimeContext(
                 new RuntimeUDFContext(
                         taskInfo,
                         getClass().getClassLoader(),
                         new ExecutionConfig(),
-                        new HashMap<String, Future<Path>>(),
-                        new HashMap<String, Accumulator<?, ?>>(),
+                        new HashMap<>(),
+                        new HashMap<>(),
                         UnregisteredMetricsGroup.createOperatorMetricGroup()));
 
-        
assertEquals(inputFormat.getRuntimeContext().getTaskInfo().getIndexOfThisSubtask(),
 1);
-        assertEquals(
-                
inputFormat.getRuntimeContext().getTaskInfo().getNumberOfParallelSubtasks(), 3);
+        
assertThat(inputFormat.getRuntimeContext().getTaskInfo().getIndexOfThisSubtask())
+                .isEqualTo(1);

Review Comment:
   ```suggestion
                   .isOne();
   ```



##########
flink-core/src/test/java/org/apache/flink/api/common/operators/base/InnerJoinOperatorBaseTest.java:
##########
@@ -76,51 +68,46 @@ public void join(String first, String second, 
Collector<Integer> out)
                                 new int[0],
                                 "TestJoiner");
 
-        List<String> inputData1 = new ArrayList<String>(Arrays.asList("foo", 
"bar", "foobar"));
-        List<String> inputData2 = new 
ArrayList<String>(Arrays.asList("foobar", "foo"));
-        List<Integer> expected = new ArrayList<Integer>(Arrays.asList(3, 3, 6, 
6));
-
-        try {
-            ExecutionConfig executionConfig = new ExecutionConfig();
-            executionConfig.disableObjectReuse();
-            List<Integer> resultSafe =
-                    base.executeOnCollections(inputData1, inputData2, null, 
executionConfig);
-            executionConfig.enableObjectReuse();
-            List<Integer> resultRegular =
-                    base.executeOnCollections(inputData1, inputData2, null, 
executionConfig);
-
-            assertEquals(expected, resultSafe);
-            assertEquals(expected, resultRegular);
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getMessage());
-        }
+        List<String> inputData1 = new ArrayList<>(Arrays.asList("foo", "bar", 
"foobar"));
+        List<String> inputData2 = new ArrayList<>(Arrays.asList("foobar", 
"foo"));
+        List<Integer> expected = new ArrayList<>(Arrays.asList(3, 3, 6, 6));
+
+        ExecutionConfig executionConfig = new ExecutionConfig();
+        executionConfig.disableObjectReuse();
+        List<Integer> resultSafe =
+                base.executeOnCollections(inputData1, inputData2, null, 
executionConfig);
+        executionConfig.enableObjectReuse();
+        List<Integer> resultRegular =
+                base.executeOnCollections(inputData1, inputData2, null, 
executionConfig);
+
+        assertThat(resultSafe).isEqualTo(expected);
+        assertThat(resultRegular).isEqualTo(expected);
     }
 
     @Test
-    public void testJoinRich() {
+    void testJoinRich() throws Exception {
         final AtomicBoolean opened = new AtomicBoolean(false);
         final AtomicBoolean closed = new AtomicBoolean(false);
         final String taskName = "Test rich join function";
 
         final RichFlatJoinFunction<String, String, Integer> joiner =
                 new RichFlatJoinFunction<String, String, Integer>() {
                     @Override
-                    public void open(OpenContext openContext) throws Exception 
{
+                    public void open(OpenContext openContext) {
                         opened.compareAndSet(false, true);
-                        assertEquals(0, 
getRuntimeContext().getTaskInfo().getIndexOfThisSubtask());
-                        assertEquals(
-                                1, 
getRuntimeContext().getTaskInfo().getNumberOfParallelSubtasks());
+                        
assertThat(getRuntimeContext().getTaskInfo().getIndexOfThisSubtask())
+                                .isZero();
+                        
assertThat(getRuntimeContext().getTaskInfo().getNumberOfParallelSubtasks())
+                                .isEqualTo(1);

Review Comment:
   ```suggestion
                                   .isOne();
   ```



##########
flink-core/src/test/java/org/apache/flink/api/common/typeutils/TypeInformationTestBase.java:
##########
@@ -115,7 +115,7 @@ public void testGetTotalFields() {
         for (T typeInfo : testData) {
             assertThat(typeInfo.getTotalFields())
                     .as("Number of total fields must be at least 1")
-                    .isGreaterThan(0);

Review Comment:
   The public of this method can be removed.



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