Jiabao-Sun commented on code in PR #23244:
URL: https://github.com/apache/flink/pull/23244#discussion_r1300257983
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -127,8 +125,13 @@ public void testHandleStreamingJobsWhenNotEnoughSlot()
throws Exception {
fail("Job should fail.");
} catch (JobExecutionException e) {
- assertThat(e, FlinkMatchers.containsMessage("Job execution
failed"));
- assertThat(e,
FlinkMatchers.containsCause(NoResourceAvailableException.class));
+ assertThat(e)
+ .satisfies(matching(FlinkMatchers.containsMessage("Job
execution failed")));
+ assertThat(e)
+ .satisfies(
+ matching(
+ FlinkMatchers.containsCause(
Review Comment:
How about `assertThatThrownBy(() ->
runHandleJobsWhenNotEnoughSlots(jobGraph))...`.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -498,15 +501,15 @@ public void
testJobWithAllVerticesFailingDuringInstantiation() throws Exception
fail("Job should fail.");
} catch (JobExecutionException e) {
- assertTrue(findThrowable(e, Exception.class).isPresent());
- assertTrue(
+ assertThat(findThrowable(e, Exception.class)).isPresent();
+ assertThat(
Review Comment:
same as above.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -670,11 +674,13 @@ public void
testOutOfMemoryErrorMessageEnrichmentInJobVertexInitialization() thr
try {
jobResultFuture.get();
} catch (ExecutionException e) {
- assertThat(e,
FlinkMatchers.containsCause(OutOfMemoryError.class));
- assertThat(
- e,
- FlinkMatchers.containsMessage(
- "Java heap space. A heap space-related
out-of-memory error has occurred."));
+ assertThat(e)
+
.satisfies(matching(FlinkMatchers.containsCause(OutOfMemoryError.class)));
+ assertThat(e)
+ .satisfies(
+ matching(
+ FlinkMatchers.containsMessage(
+ "Java heap space. A heap
space-related out-of-memory error has occurred.")));
Review Comment:
```java
assertThatFuture(jobResultFuture)
.eventuallyFailsWith(ExecutionException.class)
. satisfies(...)
```
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -628,19 +631,20 @@ public void
testOutOfMemoryErrorMessageEnrichmentInJobVertexFinalization() throw
try {
jobResultFuture.get().toJobExecutionResult(getClass().getClassLoader());
} catch (JobExecutionException e) {
- assertThat(e,
FlinkMatchers.containsCause(OutOfMemoryError.class));
+ assertThat(e)
+
.satisfies(matching(FlinkMatchers.containsCause(OutOfMemoryError.class)));
assertThat(
- findThrowable(e, OutOfMemoryError.class)
- .map(OutOfMemoryError::getMessage)
- .get(),
- startsWith(
- "Java heap space. A heap space-related
out-of-memory error has occurred."));
+ findThrowable(e, OutOfMemoryError.class)
+ .map(OutOfMemoryError::getMessage)
+ .get())
+ .startsWith(
+ "Java heap space. A heap space-related
out-of-memory error has occurred.");
Review Comment:
How about `assertThatThrownBy`
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -255,14 +258,14 @@ public void testTwoInputJobFailingEdgeMismatch() throws
Exception {
fail("Job should fail.");
} catch (JobExecutionException e) {
- assertTrue(findThrowable(e,
ArrayIndexOutOfBoundsException.class).isPresent());
- assertTrue(findThrowableWithMessage(e, "2").isPresent());
+ assertThat(findThrowable(e,
ArrayIndexOutOfBoundsException.class)).isPresent();
+ assertThat(findThrowableWithMessage(e, "2")).isPresent();
}
Review Comment:
How about `assertThatThrownBy(() ->
miniCluster.executeJobBlocking(jobGraph))`
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -374,14 +377,14 @@ public void testJobWithAFailingSenderVertex() throws
Exception {
fail("Job should fail.");
} catch (JobExecutionException e) {
- assertTrue(findThrowable(e, Exception.class).isPresent());
- assertTrue(findThrowableWithMessage(e, "Test
exception").isPresent());
+ assertThat(findThrowable(e, Exception.class)).isPresent();
+ assertThat(findThrowableWithMessage(e, "Test
exception")).isPresent();
Review Comment:
same as above.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -422,14 +425,14 @@ public void
testJobWithAnOccasionallyFailingSenderVertex() throws Exception {
fail("Job should fail.");
} catch (JobExecutionException e) {
- assertTrue(findThrowable(e, Exception.class).isPresent());
- assertTrue(findThrowableWithMessage(e, "Test
exception").isPresent());
+ assertThat(findThrowable(e, Exception.class)).isPresent();
+ assertThat(findThrowableWithMessage(e, "Test
exception")).isPresent();
Review Comment:
same as above.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -460,14 +463,14 @@ public void testJobWithAFailingReceiverVertex() throws
Exception {
fail("Job should fail.");
} catch (JobExecutionException e) {
- assertTrue(findThrowable(e, Exception.class).isPresent());
- assertTrue(findThrowableWithMessage(e, "Test
exception").isPresent());
+ assertThat(findThrowable(e, Exception.class)).isPresent();
+ assertThat(findThrowableWithMessage(e, "Test
exception")).isPresent();
Review Comment:
same as above.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -547,15 +550,15 @@ public void
testJobWithSomeVerticesFailingDuringInstantiation() throws Exception
fail("Job should fail.");
} catch (JobExecutionException e) {
- assertTrue(findThrowable(e, Exception.class).isPresent());
- assertTrue(
+ assertThat(findThrowable(e, Exception.class)).isPresent();
+ assertThat(
Review Comment:
same as above.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java:
##########
@@ -593,12 +596,12 @@ public void testCallFinalizeOnMasterBeforeJobCompletes()
throws Exception {
jobResultFuture.get().toJobExecutionResult(getClass().getClassLoader());
- assertTrue(WaitOnFinalizeJobVertex.finalizedOnMaster.get());
+
assertThat(WaitOnFinalizeJobVertex.finalizedOnMaster.get()).isTrue();
Review Comment:
```suggestion
assertThat(WaitOnFinalizeJobVertex.finalizedOnMaster).isTrue();
```
##########
flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java:
##########
@@ -33,16 +30,14 @@
import java.net.ServerSocket;
import java.net.UnknownHostException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mockStatic;
/** Tests for the network utilities. */
-@RunWith(PowerMockRunner.class)
public class ConnectionUtilsTest {
Review Comment:
Can be package private?
--
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]