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


##########
flink-runtime/src/test/java/org/apache/flink/runtime/state/SnapshotDirectoryTest.java:
##########
@@ -19,180 +19,167 @@
 package org.apache.flink.runtime.state;
 
 import org.apache.flink.util.FileUtils;
-import org.apache.flink.util.TestLogger;
 
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.UUID;
 
-/** Tests for the {@link SnapshotDirectory}. */
-public class SnapshotDirectoryTest extends TestLogger {
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-    private static TemporaryFolder temporaryFolder;
+/** Tests for the {@link SnapshotDirectory}. */
+class SnapshotDirectoryTest {
 
-    @BeforeClass
-    public static void beforeClass() throws IOException {
-        temporaryFolder = new TemporaryFolder();
-        temporaryFolder.create();
-    }
-
-    @AfterClass
-    public static void afterClass() {
-        temporaryFolder.delete();
-    }
+    @TempDir private Path temporaryFolder;
 
     /** Tests if mkdirs for snapshot directories works. */
     @Test
-    public void mkdirs() throws Exception {
-        File folderRoot = temporaryFolder.getRoot();
+    void mkdirs() throws Exception {
+        File folderRoot = temporaryFolder.toFile();
         File newFolder = new File(folderRoot, 
String.valueOf(UUID.randomUUID()));
         File innerNewFolder = new File(newFolder, 
String.valueOf(UUID.randomUUID()));
         Path path = innerNewFolder.toPath();
 
-        Assert.assertFalse(newFolder.isDirectory());
-        Assert.assertFalse(innerNewFolder.isDirectory());
+        assertThat(newFolder).doesNotExist();
+        assertThat(innerNewFolder).doesNotExist();
         SnapshotDirectory snapshotDirectory = 
SnapshotDirectory.permanent(path);
-        Assert.assertFalse(snapshotDirectory.exists());
-        Assert.assertFalse(newFolder.isDirectory());
-        Assert.assertFalse(innerNewFolder.isDirectory());
-
-        Assert.assertTrue(snapshotDirectory.mkdirs());
-        Assert.assertTrue(newFolder.isDirectory());
-        Assert.assertTrue(innerNewFolder.isDirectory());
-        Assert.assertTrue(snapshotDirectory.exists());
+        assertThat(snapshotDirectory.exists()).isFalse();
+        assertThat(newFolder).doesNotExist();
+        assertThat(innerNewFolder).doesNotExist();

Review Comment:
   Why are these 2 asserts changed? The original asserts are :
   
   ```
           Assert.assertFalse(newFolder.isDirectory());
           Assert.assertFalse(innerNewFolder.isDirectory());
   ```
   
   I see this class has a couple of similar changes.



##########
flink-runtime/src/test/java/org/apache/flink/runtime/state/CheckpointStorageLoaderTest.java:
##########
@@ -35,114 +35,118 @@
 import org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage;
 import org.apache.flink.runtime.state.storage.JobManagerCheckpointStorage;
 import org.apache.flink.runtime.state.ttl.TtlTimeProvider;
+import org.apache.flink.testutils.junit.utils.TempDirUtils;
 import org.apache.flink.util.DynamicCodeLoadingException;
-import org.apache.flink.util.TestLogger;
 
 import org.hamcrest.Description;
 import org.hamcrest.Matcher;
-import org.hamcrest.Matchers;
 import org.hamcrest.TypeSafeMatcher;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Collection;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.HamcrestCondition.matching;
+
 /** This test validates that checkpoint storage is properly loaded from 
configuration. */
-public class CheckpointStorageLoaderTest extends TestLogger {
+class CheckpointStorageLoaderTest {
+
+    private final Logger LOG = 
LoggerFactory.getLogger(CheckpointStorageLoaderTest.class);
 
-    @Rule public final TemporaryFolder tmp = new TemporaryFolder();
+    @TempDir private java.nio.file.Path tmp;
 
     private final ClassLoader cl = getClass().getClassLoader();
 
     @Test
-    public void testNoCheckpointStorageDefined() throws Exception {
-        Assert.assertFalse(
-                CheckpointStorageLoader.fromConfig(new Configuration(), cl, 
null).isPresent());
+    void testNoCheckpointStorageDefined() throws Exception {
+        assertThat(CheckpointStorageLoader.fromConfig(new Configuration(), cl, 
null).isPresent())
+                .isFalse();

Review Comment:
   ```suggestion
           assertThat(CheckpointStorageLoader.fromConfig(new Configuration(), 
cl, null)).isNotPresent();
   ```



##########
flink-runtime/src/test/java/org/apache/flink/runtime/state/SerializationProxiesTest.java:
##########
@@ -272,46 +271,45 @@ public void testBroadcastStateMetaInfoSerialization() 
throws Exception {
         RegisteredBroadcastStateBackendMetaInfo<?, ?> restoredMetaInfo =
                 new RegisteredBroadcastStateBackendMetaInfo<>(snapshot);
 
-        Assert.assertEquals(name, restoredMetaInfo.getName());
-        Assert.assertEquals(
-                OperatorStateHandle.Mode.BROADCAST, 
restoredMetaInfo.getAssignmentMode());
-        Assert.assertEquals(keySerializer, 
restoredMetaInfo.getKeySerializer());
-        Assert.assertEquals(valueSerializer, 
restoredMetaInfo.getValueSerializer());
+        assertThat(restoredMetaInfo.getName()).isEqualTo(name);
+        assertThat(restoredMetaInfo.getAssignmentMode())
+                .isEqualTo(OperatorStateHandle.Mode.BROADCAST);
+        
assertThat(restoredMetaInfo.getKeySerializer()).isEqualTo(keySerializer);
+        
assertThat(restoredMetaInfo.getValueSerializer()).isEqualTo(valueSerializer);
     }
 
     /**
      * This test fixes the order of elements in the enum which is important 
for serialization. Do
      * not modify this test except if you are entirely sure what you are doing.
      */
     @Test
-    public void testFixTypeOrder() {
+    void testFixTypeOrder() {
         // ensure all elements are covered
-        Assert.assertEquals(7, StateDescriptor.Type.values().length);
+        assertThat(StateDescriptor.Type.values()).hasSize(7);
         // fix the order of elements to keep serialization format stable
-        Assert.assertEquals(0, StateDescriptor.Type.UNKNOWN.ordinal());
-        Assert.assertEquals(1, StateDescriptor.Type.VALUE.ordinal());
-        Assert.assertEquals(2, StateDescriptor.Type.LIST.ordinal());
-        Assert.assertEquals(3, StateDescriptor.Type.REDUCING.ordinal());
-        Assert.assertEquals(4, StateDescriptor.Type.FOLDING.ordinal());
-        Assert.assertEquals(5, StateDescriptor.Type.AGGREGATING.ordinal());
-        Assert.assertEquals(6, StateDescriptor.Type.MAP.ordinal());
+        assertThat(StateDescriptor.Type.UNKNOWN.ordinal()).isZero();
+        assertThat(StateDescriptor.Type.VALUE.ordinal()).isOne();
+        assertThat(StateDescriptor.Type.LIST.ordinal()).isEqualTo(2);
+        assertThat(StateDescriptor.Type.REDUCING.ordinal()).isEqualTo(3);
+        assertThat(StateDescriptor.Type.FOLDING.ordinal()).isEqualTo(4);
+        assertThat(StateDescriptor.Type.AGGREGATING.ordinal()).isEqualTo(5);
+        assertThat(StateDescriptor.Type.MAP.ordinal()).isEqualTo(6);
     }
 
     private void assertEqualStateMetaInfoSnapshotsLists(
             List<StateMetaInfoSnapshot> expected, List<StateMetaInfoSnapshot> 
actual) {
-        Assert.assertEquals(expected.size(), actual.size());
+        assertThat(actual.size()).isEqualTo(expected.size());

Review Comment:
   hasSameSize



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