Jiabao-Sun commented on code in PR #24670:
URL: https://github.com/apache/flink/pull/24670#discussion_r1593260020


##########
flink-core/src/test/java/org/apache/flink/util/LinkedOptionalMapTest.java:
##########
@@ -124,42 +118,50 @@ public void mergingToEmpty() {
 
         first.putAll(second);
 
-        assertThat(first.keyNames(), contains("a", "b", "c", "d"));
+        assertThat(first.keyNames()).contains("a", "b", "c", "d");
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void unwrapOptionalsWithMissingValueThrows() {
-        LinkedOptionalMap<Class<?>, String> map = new LinkedOptionalMap<>();
+    @Test
+    void unwrapOptionalsWithMissingValueThrows() {
+        assertThatThrownBy(
+                        () -> {
+                            LinkedOptionalMap<Class<?>, String> map = new 
LinkedOptionalMap<>();
 
-        map.put("a", String.class, null);
+                            map.put("a", String.class, null);
 
-        map.unwrapOptionals();
+                            map.unwrapOptionals();
+                        })
+                .isInstanceOf(IllegalStateException.class);
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void unwrapOptionalsWithMissingKeyThrows() {
-        LinkedOptionalMap<Class<?>, String> map = new LinkedOptionalMap<>();
+    @Test
+    void unwrapOptionalsWithMissingKeyThrows() {
+        assertThatThrownBy(
+                        () -> {
+                            LinkedOptionalMap<Class<?>, String> map = new 
LinkedOptionalMap<>();
 
-        map.put("a", null, "blabla");
+                            map.put("a", null, "blabla");
 
-        map.unwrapOptionals();
+                            map.unwrapOptionals();
+                        })
+                .isInstanceOf(IllegalStateException.class);
     }
 
     @Test
-    public void unwrapOptionalsPreservesOrder() {
+    void unwrapOptionalsPreservesOrder() {
         LinkedOptionalMap<Class<?>, String> map = new LinkedOptionalMap<>();
 
         map.put("a", String.class, "aaa");
         map.put("b", Boolean.class, "bbb");
 
         LinkedHashMap<Class<?>, String> m = map.unwrapOptionals();
 
-        assertThat(m.keySet(), contains(String.class, Boolean.class));
-        assertThat(m.values(), contains("aaa", "bbb"));
+        assertThat(m).containsKey(String.class);

Review Comment:
   ```suggestion
           assertThat(m).containsKeys(String.class, Boolean.class);
   ```



##########
flink-core/src/test/java/org/apache/flink/util/concurrent/ConjunctFutureTest.java:
##########
@@ -37,43 +37,41 @@
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-/** Tests for the {@link ConjunctFuture} and its sub classes. */
-@RunWith(Parameterized.class)
-public class ConjunctFutureTest extends TestLogger {
+/** Tests for the {@link ConjunctFuture} and its subclasses. */
+@ExtendWith(ParameterizedTestExtension.class)
+class ConjunctFutureTest {
 
-    @Parameterized.Parameters
+    @Parameters
     public static Collection<FutureFactory> parameters() {

Review Comment:
   ```suggestion
       private static Collection<FutureFactory> parameters() {
   ```



##########
flink-core/src/test/java/org/apache/flink/util/SerializedValueTest.java:
##########
@@ -20,62 +20,57 @@
 
 import org.apache.flink.core.testutils.CommonTestUtils;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.util.Arrays;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 /** Tests for the {@link SerializedValue}. */
-public class SerializedValueTest {
+class SerializedValueTest {
 
     @Test
-    public void testSimpleValue() {
-        try {
-            final String value = "teststring";
-
-            SerializedValue<String> v = new SerializedValue<>(value);
-            SerializedValue<String> copy = 
CommonTestUtils.createCopySerializable(v);
-
-            assertEquals(value, 
v.deserializeValue(getClass().getClassLoader()));
-            assertEquals(value, 
copy.deserializeValue(getClass().getClassLoader()));
-
-            assertEquals(v, copy);
-            assertEquals(v.hashCode(), copy.hashCode());
-
-            assertNotNull(v.toString());
-            assertNotNull(copy.toString());
-
-            assertNotEquals(0, v.getByteArray().length);
-            assertArrayEquals(v.getByteArray(), copy.getByteArray());
-
-            byte[] bytes = v.getByteArray();
-            SerializedValue<String> saved =
-                    SerializedValue.fromBytes(Arrays.copyOf(bytes, 
bytes.length));
-            assertEquals(v, saved);
-            assertArrayEquals(v.getByteArray(), saved.getByteArray());
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getMessage());
-        }
+    void testSimpleValue() throws Exception {
+        final String value = "teststring";
+
+        SerializedValue<String> v = new SerializedValue<>(value);
+        SerializedValue<String> copy = 
CommonTestUtils.createCopySerializable(v);
+
+        
assertThat(v.deserializeValue(getClass().getClassLoader())).isEqualTo(value);
+        
assertThat(copy.deserializeValue(getClass().getClassLoader())).isEqualTo(value);
+
+        assertThat(copy).isEqualTo(v);
+        assertThat(copy).hasSameHashCodeAs(v.hashCode());
+
+        assertThat(v.toString()).isNotNull();
+        assertThat(copy.toString()).isNotNull();
+
+        assertThat(v.getByteArray().length).isNotEqualTo(0);

Review Comment:
   ```suggestion
           assertThat(v.getByteArray()).isNotEmpty();
   ```



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