[GitHub] [flink] XComp commented on a diff in pull request #20258: [FLINK-28522][tests][JUnit5 migration] flink-sequence-file

2022-10-25 Thread GitBox


XComp commented on code in PR #20258:
URL: https://github.com/apache/flink/pull/20258#discussion_r1004201984


##
flink-formats/flink-sequence-file/src/test/java/org/apache/flink/formats/sequencefile/SerializableHadoopConfigurationTest.java:
##
@@ -19,70 +19,54 @@
 package org.apache.flink.formats.sequencefile;
 
 import org.apache.hadoop.conf.Configuration;
-import org.hamcrest.Description;
-import org.hamcrest.TypeSafeMatcher;
-import org.junit.Before;
-import org.junit.Test;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.HamcrestCondition.matching;
-
 /** Tests for the {@link SerializableHadoopConfiguration}. */
-public class SerializableHadoopConfigurationTest {
+class SerializableHadoopConfigurationTest {
 
 private static final String TEST_KEY = "test-key";
 
 private static final String TEST_VALUE = "test-value";
 
 private Configuration configuration;
 
-@Before
-public void createConfigWithCustomProperty() {
+@BeforeEach
+void createConfigWithCustomProperty() {
 this.configuration = new Configuration();
 configuration.set(TEST_KEY, TEST_VALUE);
 }
 
 @Test
-public void customPropertiesSurviveSerializationDeserialization()
+void customPropertiesSurviveSerializationDeserialization()
 throws IOException, ClassNotFoundException {
 final SerializableHadoopConfiguration serializableConfigUnderTest =
 new SerializableHadoopConfiguration(configuration);
 final byte[] serializedConfigUnderTest = 
serializeAndGetBytes(serializableConfigUnderTest);
 final SerializableHadoopConfiguration deserializableConfigUnderTest =
 deserializeAndGetConfiguration(serializedConfigUnderTest);
 
-assertThat(deserializableConfigUnderTest.get())
-.satisfies(matching(hasTheSamePropertiesAs(configuration)));
-}
-
-// Matchers 
 //
-
-private static TypeSafeMatcher hasTheSamePropertiesAs(
-final Configuration expectedConfig) {
-return new TypeSafeMatcher() {
-@Override
-protected boolean matchesSafely(Configuration actualConfig) {
-final String value = actualConfig.get(TEST_KEY);
-return actualConfig != expectedConfig
-&& value != null
-&& expectedConfig.get(TEST_KEY).equals(value);
-}
-
-@Override
-public void describeTo(Description description) {
-description
-.appendText("a Hadoop Configuration with property: 
key=")
-.appendValue(TEST_KEY)
-.appendText(" and value=")
-.appendValue(TEST_VALUE);
-}
-};
+
Assertions.assertThat(deserializableConfigUnderTest.get())
+.matches(
+actualConfig -> {
+final String value = actualConfig.get(TEST_KEY);
+return actualConfig != 
serializableConfigUnderTest.get()
+&& value != null
+&& serializableConfigUnderTest
+.get()
+.get(TEST_KEY)
+.equals(value);
+})
+.describedAs(

Review Comment:
   It doesn't look like it does what it suppose to do. You can double check by 
making the test fail. The descriptive error message is not printed.



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



[GitHub] [flink] XComp commented on a diff in pull request #20258: [FLINK-28522][tests][JUnit5 migration] flink-sequence-file

2022-10-06 Thread GitBox


XComp commented on code in PR #20258:
URL: https://github.com/apache/flink/pull/20258#discussion_r989176628


##
flink-formats/flink-sequence-file/src/test/java/org/apache/flink/formats/sequencefile/SequenceStreamingFileSinkITCase.java:
##
@@ -50,18 +51,17 @@
  * Integration test case for writing bulk encoded files with the {@link 
StreamingFileSink} with
  * SequenceFile.
  */
-public class SequenceStreamingFileSinkITCase extends AbstractTestBase {
+@ExtendWith(MiniClusterExtension.class)
+@Timeout(20)

Review Comment:
   There was a community discussion on trying to avoid timeouts (see 
[discussion 
thread](https://lists.apache.org/thread/q11t0y3qsw07lkb811037h4mvx0r7ncn) and 
[corresponding Flink coding 
guidelines](https://flink.apache.org/contributing/code-style-and-quality-common.html#avoid-timeouts-in-junit-tests)).
   The decision was only made on unit tests but I don't see why the same 
wouldn't also apply for integration tests. WDYT?



##
flink-formats/flink-sequence-file/src/test/java/org/apache/flink/formats/sequencefile/SerializableHadoopConfigurationTest.java:
##
@@ -19,70 +19,51 @@
 package org.apache.flink.formats.sequencefile;
 
 import org.apache.hadoop.conf.Configuration;
-import org.hamcrest.Description;
-import org.hamcrest.TypeSafeMatcher;
-import org.junit.Before;
-import org.junit.Test;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.HamcrestCondition.matching;
-
 /** Tests for the {@link SerializableHadoopConfiguration}. */
-public class SerializableHadoopConfigurationTest {
+class SerializableHadoopConfigurationTest {
 
 private static final String TEST_KEY = "test-key";
 
 private static final String TEST_VALUE = "test-value";
 
 private Configuration configuration;
 
-@Before
-public void createConfigWithCustomProperty() {
+@BeforeEach
+void createConfigWithCustomProperty() {
 this.configuration = new Configuration();
 configuration.set(TEST_KEY, TEST_VALUE);
 }
 
 @Test
-public void customPropertiesSurviveSerializationDeserialization()
+void customPropertiesSurviveSerializationDeserialization()
 throws IOException, ClassNotFoundException {
 final SerializableHadoopConfiguration serializableConfigUnderTest =
 new SerializableHadoopConfiguration(configuration);
 final byte[] serializedConfigUnderTest = 
serializeAndGetBytes(serializableConfigUnderTest);
 final SerializableHadoopConfiguration deserializableConfigUnderTest =
 deserializeAndGetConfiguration(serializedConfigUnderTest);
 
-assertThat(deserializableConfigUnderTest.get())
-.satisfies(matching(hasTheSamePropertiesAs(configuration)));
-}
-
-// Matchers 
 //
-
-private static TypeSafeMatcher hasTheSamePropertiesAs(
-final Configuration expectedConfig) {
-return new TypeSafeMatcher() {
-@Override
-protected boolean matchesSafely(Configuration actualConfig) {
-final String value = actualConfig.get(TEST_KEY);
-return actualConfig != expectedConfig
-&& value != null
-&& expectedConfig.get(TEST_KEY).equals(value);
-}
-
-@Override
-public void describeTo(Description description) {
-description
-.appendText("a Hadoop Configuration with property: 
key=")
-.appendValue(TEST_KEY)
-.appendText(" and value=")
-.appendValue(TEST_VALUE);
-}
-};
+
Assertions.assertThat(deserializableConfigUnderTest.get())
+.matches(
+actualConfig -> {
+final String value = actualConfig.get(TEST_KEY);
+return actualConfig != configuration

Review Comment:
   ```suggestion
   return actualConfig != 
serializableConfigUnderTest
   ```
   nit: I'd prefer keeping it in the test method's context as much as possible.



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