This is an automated email from the ASF dual-hosted git repository. fanrui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/flink.git
commit 6453a48e70f542ee2618da10cb44a480e56fe0f3 Author: 1996fanrui <[email protected]> AuthorDate: Fri Jun 30 13:32:02 2023 +0800 [hotfix] Migrate StreamExecutionEnvironmentTest to Junit5 and AssertJ --- .../coordinator/SourceCoordinatorProviderTest.java | 36 ++++++++++------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorProviderTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorProviderTest.java index 5452c4c0e06..348e3e048c7 100644 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorProviderTest.java +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorProviderTest.java @@ -29,26 +29,24 @@ import org.apache.flink.runtime.operators.coordination.OperatorCoordinator; import org.apache.flink.runtime.operators.coordination.RecreateOnResetOperatorCoordinator; import org.apache.flink.runtime.source.event.ReaderRegistrationEvent; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Duration; import java.util.concurrent.CompletableFuture; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; /** Unit tests for {@link SourceCoordinatorProvider}. */ -public class SourceCoordinatorProviderTest { +class SourceCoordinatorProviderTest { private static final OperatorID OPERATOR_ID = new OperatorID(1234L, 5678L); private static final int NUM_SPLITS = 10; private SourceCoordinatorProvider<MockSourceSplit> provider; - @Before - public void setup() { + @BeforeEach + void setup() { provider = new SourceCoordinatorProvider<>( "SourceCoordinatorProviderTest", @@ -60,14 +58,14 @@ public class SourceCoordinatorProviderTest { } @Test - public void testCreate() throws Exception { + void testCreate() throws Exception { OperatorCoordinator coordinator = provider.create(new MockOperatorCoordinatorContext(OPERATOR_ID, NUM_SPLITS)); - assertTrue(coordinator instanceof RecreateOnResetOperatorCoordinator); + assertThat(coordinator).isInstanceOf(RecreateOnResetOperatorCoordinator.class); } @Test - public void testCheckpointAndReset() throws Exception { + void testCheckpointAndReset() throws Exception { final OperatorCoordinator.Context context = new MockOperatorCoordinatorContext(OPERATOR_ID, NUM_SPLITS); final RecreateOnResetOperatorCoordinator coordinator = @@ -94,19 +92,17 @@ public class SourceCoordinatorProviderTest { coordinator.resetToCheckpoint(0L, bytes); final SourceCoordinator<?, ?> restoredSourceCoordinator = (SourceCoordinator<?, ?>) coordinator.getInternalCoordinator(); - assertNotEquals( - "The restored source coordinator should be a different instance", - restoredSourceCoordinator, - sourceCoordinator); + assertThat(sourceCoordinator) + .as("The restored source coordinator should be a different instance") + .isNotEqualTo(restoredSourceCoordinator); // FLINK-21452: do not (re)store registered readers - assertEquals( - "There should be no registered reader.", - 0, - restoredSourceCoordinator.getContext().registeredReaders().size()); + assertThat(restoredSourceCoordinator.getContext().registeredReaders()) + .as("There should be no registered reader.") + .isEmpty(); } @Test - public void testCallAsyncExceptionFailsJob() throws Exception { + void testCallAsyncExceptionFailsJob() throws Exception { MockOperatorCoordinatorContext context = new MockOperatorCoordinatorContext(OPERATOR_ID, NUM_SPLITS); RecreateOnResetOperatorCoordinator coordinator =
