Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-05-11 Thread via GitHub


1996fanrui commented on PR #24670:
URL: https://github.com/apache/flink/pull/24670#issuecomment-2105650755

   > @Jiabao-Sun @1996fanrui I will open hotfix to mater.
   
   Sorry, I didn't notice it. I start fix it after I received the CI alert. 


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



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-05-11 Thread via GitHub


GOODBOY008 commented on PR #24670:
URL: https://github.com/apache/flink/pull/24670#issuecomment-2105648555

   
[workflow_dispatch](https://github.com/apache/flink/actions/runs/9042536161/job/24849180888#step:6:903)


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



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-05-11 Thread via GitHub


GOODBOY008 commented on PR #24670:
URL: https://github.com/apache/flink/pull/24670#issuecomment-2105648441

   @Jiabao-Sun @1996fanrui I will open hotfix to mater.


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



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-05-11 Thread via GitHub


1996fanrui merged PR #24670:
URL: https://github.com/apache/flink/pull/24670


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



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-05-09 Thread via GitHub


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


##
flink-core/src/test/java/org/apache/flink/util/AbstractIDTest.java:
##
@@ -71,16 +67,16 @@ public void testCompare() throws Exception {
 AbstractID id10 = new AbstractID(Long.MIN_VALUE, Long.MAX_VALUE);
 
 // test self equality
-assertEquals(0, 
id1.compareTo(CommonTestUtils.createCopySerializable(id1)));
-assertEquals(0, 
id2.compareTo(CommonTestUtils.createCopySerializable(id2)));
-assertEquals(0, 
id3.compareTo(CommonTestUtils.createCopySerializable(id3)));
-assertEquals(0, 
id4.compareTo(CommonTestUtils.createCopySerializable(id4)));
-assertEquals(0, 
id5.compareTo(CommonTestUtils.createCopySerializable(id5)));
-assertEquals(0, 
id6.compareTo(CommonTestUtils.createCopySerializable(id6)));
-assertEquals(0, 
id7.compareTo(CommonTestUtils.createCopySerializable(id7)));
-assertEquals(0, 
id8.compareTo(CommonTestUtils.createCopySerializable(id8)));
-assertEquals(0, 
id9.compareTo(CommonTestUtils.createCopySerializable(id9)));
-assertEquals(0, 
id10.compareTo(CommonTestUtils.createCopySerializable(id10)));
+
assertThat(id1.compareTo(CommonTestUtils.createCopySerializable(id1))).isZero();

Review Comment:
   ```suggestion
   
assertThat(id1).isEqualByComparingTo(CommonTestUtils.createCopySerializable(id1));
   ```
   
   The rest can be updated as well



##
flink-core/src/test/java/org/apache/flink/util/TimeUtilsTest.java:
##
@@ -20,173 +20,153 @@
 
 import org.apache.flink.api.common.time.Time;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.time.Duration;
 import java.time.temporal.ChronoUnit;
 import java.util.concurrent.TimeUnit;
 
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 /** Tests for {@link TimeUtils}. */
-public class TimeUtilsTest {
+class TimeUtilsTest {
 
 @Test
-public void testParseDurationNanos() {
-assertEquals(424562, TimeUtils.parseDuration("424562ns").getNano());
-assertEquals(424562, TimeUtils.parseDuration("424562nano").getNano());
-assertEquals(424562, TimeUtils.parseDuration("424562nanos").getNano());
-assertEquals(424562, 
TimeUtils.parseDuration("424562nanosecond").getNano());
-assertEquals(424562, 
TimeUtils.parseDuration("424562nanoseconds").getNano());
-assertEquals(424562, TimeUtils.parseDuration("424562 ns").getNano());
+void testParseDurationNanos() {
+
assertThat(TimeUtils.parseDuration("424562ns").getNano()).isEqualTo(424562);
+
assertThat(TimeUtils.parseDuration("424562nano").getNano()).isEqualTo(424562);
+
assertThat(TimeUtils.parseDuration("424562nanos").getNano()).isEqualTo(424562);
+
assertThat(TimeUtils.parseDuration("424562nanosecond").getNano()).isEqualTo(424562);
+
assertThat(TimeUtils.parseDuration("424562nanoseconds").getNano()).isEqualTo(424562);
+assertThat(TimeUtils.parseDuration("424562 
ns").getNano()).isEqualTo(424562);
 }
 
 @Test
-public void testParseDurationMicros() {
-assertEquals(565731 * 1000L, 
TimeUtils.parseDuration("565731µs").getNano());
-assertEquals(565731 * 1000L, 
TimeUtils.parseDuration("565731micro").getNano());
-assertEquals(565731 * 1000L, 
TimeUtils.parseDuration("565731micros").getNano());
-assertEquals(565731 * 1000L, 
TimeUtils.parseDuration("565731microsecond").getNano());
-assertEquals(565731 * 1000L, 
TimeUtils.parseDuration("565731microseconds").getNano());
-assertEquals(565731 * 1000L, TimeUtils.parseDuration("565731 
µs").getNano());
+void testParseDurationMicros() {
+
assertThat(TimeUtils.parseDuration("565731µs").getNano()).isEqualTo(565731 * 
1000L);
+
assertThat(TimeUtils.parseDuration("565731micro").getNano()).isEqualTo(565731 * 
1000L);
+
assertThat(TimeUtils.parseDuration("565731micros").getNano()).isEqualTo(565731 
* 1000L);
+assertThat(TimeUtils.parseDuration("565731microsecond").getNano())
+.isEqualTo(565731 * 1000L);
+assertThat(TimeUtils.parseDuration("565731microseconds").getNano())
+.isEqualTo(565731 * 1000L);
+assertThat(TimeUtils.parseDuration("565731 
µs").getNano()).isEqualTo(565731 * 1000L);
 }
 
 @Test
-public void testParseDurationMillis() {
-assertEquals(1234, TimeUtils.parseDuration("1234").toMillis());
-assertEquals(1234, TimeUtils.parseDuration("1234ms").toMillis());
-assertEquals(1234, 

Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-05-07 Thread via GitHub


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


##
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 v = new SerializedValue<>(value);
-SerializedValue 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 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 v = new SerializedValue<>(value);
+SerializedValue 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());

Review Comment:
   ```suggestion
   assertThat(copy).hasSameHashCodeAs(v);
   ```



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



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-05-07 Thread via GitHub


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, String> map = new LinkedOptionalMap<>();
+@Test
+void unwrapOptionalsWithMissingValueThrows() {
+assertThatThrownBy(
+() -> {
+LinkedOptionalMap, 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, String> map = new LinkedOptionalMap<>();
+@Test
+void unwrapOptionalsWithMissingKeyThrows() {
+assertThatThrownBy(
+() -> {
+LinkedOptionalMap, 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, String> map = new LinkedOptionalMap<>();
 
 map.put("a", String.class, "aaa");
 map.put("b", Boolean.class, "bbb");
 
 LinkedHashMap, 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 parameters() {

Review Comment:
   ```suggestion
   private static Collection 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 v = new SerializedValue<>(value);
-SerializedValue 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);
-

Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-05-07 Thread via GitHub


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


##
flink-core/src/test/java/org/apache/flink/util/CloseableIteratorTest.java:
##
@@ -17,48 +17,48 @@
 
 package org.apache.flink.util;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.util.ArrayList;
 import java.util.List;
 
 import static java.util.Arrays.asList;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertFalse;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 /** {@link CloseableIterator} test. */
 @SuppressWarnings("unchecked")
-public class CloseableIteratorTest {
+class CloseableIteratorTest {
 
 private static final String[] ELEMENTS = new String[] {"element-1", 
"element-2"};
 
 @Test
-public void testFlattenEmpty() throws Exception {
+void testFlattenEmpty() throws Exception {
 List> iterators =
 asList(
 CloseableIterator.flatten(),
 CloseableIterator.flatten(CloseableIterator.empty()),
 
CloseableIterator.flatten(CloseableIterator.flatten()));
 for (CloseableIterator i : iterators) {
-assertFalse(i.hasNext());
+assertThat(i.hasNext()).isFalse();

Review Comment:
   ```suggestion
   assertThat(i).isExhausted();
   ```



##
flink-core/src/test/java/org/apache/flink/util/AbstractIDTest.java:
##
@@ -20,44 +20,40 @@
 
 import org.apache.flink.core.testutils.CommonTestUtils;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.io.InputStream;
 
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** This class contains tests for the {@link org.apache.flink.util.AbstractID} 
class. */
-public class AbstractIDTest extends TestLogger {
+class AbstractIDTest {
 
 /** Tests the serialization/deserialization of an abstract ID. */
 @Test
-public void testSerialization() throws Exception {
+void testSerialization() throws Exception {
 final AbstractID origID = new AbstractID();
 final AbstractID copyID = 
CommonTestUtils.createCopySerializable(origID);
 
-assertEquals(origID.hashCode(), copyID.hashCode());
-assertEquals(origID, copyID);
+assertThat(copyID.hashCode()).isEqualTo(origID.hashCode());

Review Comment:
   ```suggestion
   assertThat(copyID).hasSameHashCodeAs(origID);
   ```



##
flink-core/src/test/java/org/apache/flink/util/InstantiationUtilTest.java:
##
@@ -99,39 +97,40 @@ private String createProxyDefinition(String proxyName) {
 }
 
 @Test
-public void testInstantiationOfStringValue() {
+void testInstantiationOfStringValue() {
 StringValue stringValue = 
InstantiationUtil.instantiate(StringValue.class, null);
-assertNotNull(stringValue);
+assertThat(Optional.of(stringValue)).isNotNull();

Review Comment:
   ```java
   Object stringValue = 
InstantiationUtil.instantiate(StringValue.class, null);
   assertThat(stringValue).isNotNull();
   ```



##
flink-core/src/test/java/org/apache/flink/util/CollectionUtilTest.java:
##
@@ -138,15 +129,12 @@ public void testCheckedSubTypeCast() {
 list.add(null);
 Collection castSuccess = CollectionUtil.checkedSubTypeCast(list, 
B.class);
 Iterator iterator = castSuccess.iterator();
-Assertions.assertEquals(b, iterator.next());
-Assertions.assertEquals(c, iterator.next());
-Assertions.assertNull(iterator.next());
-Assertions.assertFalse(iterator.hasNext());
-try {
-Collection castFail = CollectionUtil.checkedSubTypeCast(list, 
C.class);
-fail("Expected ClassCastException");
-} catch (ClassCastException expected) {
-}
+assertThat(iterator.next()).isEqualTo(b);
+assertThat(iterator.next()).isEqualTo(c);
+assertThat(iterator.next()).isNull();
+assertThat(iterator.hasNext()).isFalse();

Review Comment:
   ```suggestion
   assertThat(iterator).isExhausted();
   ```



##
flink-core/src/test/java/org/apache/flink/util/FileUtilsTest.java:
##
@@ -572,8 +566,6 @@ public void testExpandDirWithForbiddenEscape() {
  * @param outputFile the path of the output file
  * @param length the size of content to generate
  * @return MD5 of the output file
- * @throws IOException
- * @throws NoSuchAlgorithmException
  */
 private static String generateTestFile(String outputFile, int length)

Review Comment:
   We don't have to delete it just 

Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-04-16 Thread via GitHub


flinkbot commented on PR #24670:
URL: https://github.com/apache/flink/pull/24670#issuecomment-2058604771

   
   ## CI report:
   
   * aae449392b8ce075a2413679ed2a0c42eaa52c68 UNKNOWN
   
   
   Bot commands
 The @flinkbot bot supports the following commands:
   
- `@flinkbot run azure` re-run the last Azure build
   


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



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: util [flink]

2024-04-16 Thread via GitHub


GOODBOY008 commented on PR #24670:
URL: https://github.com/apache/flink/pull/24670#issuecomment-2058579166

   @Jiabao-Sun @1996fanrui PTAL 


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