Jiabao-Sun commented on code in PR #23242: URL: https://github.com/apache/flink/pull/23242#discussion_r1300285624
########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientMultipartTest.java: ########## @@ -48,7 +48,7 @@ class RestClientMultipartTest { @TempDir public static Path tempDir; Review Comment: ```suggestion @TempDir private static Path tempDir; ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java: ########## @@ -196,9 +194,13 @@ public void testRestClientClosedHandling() throws Exception { restClient.close(); - FlinkAssertions.assertThatFuture(responseFuture) - .eventuallyFailsWith(ExecutionException.class) - .withCauseInstanceOf(IOException.class); + try { + responseFuture.get(); + } catch (ExecutionException ee) { + if (!ExceptionUtils.findThrowable(ee, IOException.class).isPresent()) { + throw ee; + } + } Review Comment: same as above. ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/cluster/JobManagerCustomLogHandlerTest.java: ########## @@ -105,60 +96,60 @@ private static HandlerRequest<EmptyRequestBody> createHandlerRequest(String path } @Test - public void testGetJobManagerCustomLogsValidFilename() throws Exception { + void testGetJobManagerCustomLogsValidFilename() throws Exception { File actualFile = testInstance.getFile(createHandlerRequest(VALID_LOG_FILENAME)); - assertThat(actualFile, is(notNullValue())); + assertThat(actualFile).isNotNull(); String actualContent = String.join("", Files.readAllLines(actualFile.toPath())); - assertThat(actualContent, is(VALID_LOG_CONTENT)); + assertThat(actualContent).isEqualTo(VALID_LOG_CONTENT); } @Test - public void testGetJobManagerCustomLogsValidFilenameWithPath() throws Exception { + void testGetJobManagerCustomLogsValidFilenameWithPath() throws Exception { File actualFile = testInstance.getFile( createHandlerRequest(String.format("foobar/%s", VALID_LOG_FILENAME))); - assertThat(actualFile, is(notNullValue())); + assertThat(actualFile).isNotNull(); String actualContent = String.join("", Files.readAllLines(actualFile.toPath())); - assertThat(actualContent, is(VALID_LOG_CONTENT)); + assertThat(actualContent).isEqualTo(VALID_LOG_CONTENT); } @Test - public void testGetJobManagerCustomLogsValidFilenameWithInvalidPath() throws Exception { + void testGetJobManagerCustomLogsValidFilenameWithInvalidPath() throws Exception { File actualFile = testInstance.getFile( createHandlerRequest(String.format("../%s", VALID_LOG_FILENAME))); - assertThat(actualFile, is(notNullValue())); + assertThat(actualFile).isNotNull(); String actualContent = String.join("", Files.readAllLines(actualFile.toPath())); - assertThat(actualContent, is(VALID_LOG_CONTENT)); + assertThat(actualContent).isEqualTo(VALID_LOG_CONTENT); } @Test - public void testGetJobManagerCustomLogsNotExistingFile() throws Exception { + void testGetJobManagerCustomLogsNotExistingFile() throws Exception { File actualFile = testInstance.getFile(createHandlerRequest("not-existing")); - assertThat(actualFile, is(notNullValue())); - assertFalse(actualFile.exists()); + assertThat(actualFile).isNotNull(); + assertThat(actualFile.exists()).isFalse(); Review Comment: ```suggestion assertThat(actualFile).isNotNull().exists(); ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/JobSubmitHandlerTest.java: ########## @@ -126,15 +130,15 @@ public void testSerializationFailureHandling() throws Exception { handler.handleRequest( HandlerRequest.create(request, EmptyMessageParameters.getInstance()), mockGateway); - Assert.fail(); + fail("Expected exception not thrown"); } catch (RestHandlerException rhe) { - Assert.assertEquals(HttpResponseStatus.BAD_REQUEST, rhe.getHttpResponseStatus()); + assertThat(rhe.getHttpResponseStatus()).isEqualTo(HttpResponseStatus.BAD_REQUEST); Review Comment: How about `assertThatThrownBy` ########## flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/handlers/JarRunRequestBodyTest.java: ########## @@ -21,13 +21,17 @@ import org.apache.flink.api.common.JobID; import org.apache.flink.runtime.jobgraph.RestoreMode; import org.apache.flink.runtime.rest.messages.RestRequestMarshallingTestBase; +import org.apache.flink.testutils.junit.extensions.parameterized.NoOpTestExtension; + +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Arrays; import java.util.Collections; import static org.assertj.core.api.Assertions.assertThat; /** Tests for {@link JarRunRequestBody}. */ +@ExtendWith(NoOpTestExtension.class) public class JarRunRequestBodyTest extends RestRequestMarshallingTestBase<JarRunRequestBody> { Review Comment: ```suggestion class JarRunRequestBodyTest extends RestRequestMarshallingTestBase<JarRunRequestBody> { ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestExternalHandlersITCase.java: ########## @@ -128,30 +124,23 @@ void teardown() throws Exception { void testHandlersMustBeLoaded() { final List<InboundChannelHandlerFactory> inboundChannelHandlerFactories = serverEndpoint.getInboundChannelHandlerFactories(); - assertEquals(inboundChannelHandlerFactories.size(), 2); - assertTrue( - inboundChannelHandlerFactories.get(0) instanceof Prio1InboundChannelHandlerFactory); - assertTrue( - inboundChannelHandlerFactories.get(1) instanceof Prio0InboundChannelHandlerFactory); + assertThat(inboundChannelHandlerFactories.size()).isEqualTo(2); Review Comment: ```suggestion assertThat(inboundChannelHandlerFactories).hasSize(2); ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java: ########## @@ -82,42 +79,39 @@ void testConnectionTimeout() throws Exception { new TestMessageHeaders(), EmptyMessageParameters.getInstance(), EmptyRequestBody.getInstance()); - - FlinkAssertions.assertThatFuture(future) + assertThatFuture(future) .eventuallyFailsWith(ExecutionException.class) .withCauseInstanceOf(ConnectTimeoutException.class) - .extracting(Throwable::getCause, as(InstanceOfAssertFactories.THROWABLE)) - .hasMessageContaining(unroutableIp); + .withMessageContaining(unroutableIp); } } @Test - public void testInvalidVersionRejection() throws Exception { - try (final RestClient restClient = - new RestClient(new Configuration(), Executors.directExecutor())) { - assertThatThrownBy( - () -> - restClient.sendRequest( - unroutableIp, - 80, - new TestMessageHeaders(), - EmptyMessageParameters.getInstance(), - EmptyRequestBody.getInstance(), - Collections.emptyList(), - RuntimeRestAPIVersion.V0)) - .as("The request should have been rejected due to a version mismatch.") - .isInstanceOf(IllegalArgumentException.class); - } + void testInvalidVersionRejection() throws Exception { + final RestClient restClient = + new RestClient(new Configuration(), Executors.directExecutor()); Review Comment: Why we remove the try resource code? I think it's better to close the restClient. ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java: ########## @@ -54,16 +53,14 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import static org.assertj.core.api.Assertions.as; +import static org.apache.flink.core.testutils.FlinkAssertions.assertThatFuture; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.InstanceOfAssertFactories.THROWABLE; /** Tests for {@link RestClient}. */ class RestClientTest { - @RegisterExtension - static final TestExecutorExtension<ScheduledExecutorService> EXECUTOR_EXTENSION = + private static final TestExecutorExtension<ScheduledExecutorService> EXECUTOR_RESOURCE = Review Comment: ```suggestion private static final TestExecutorExtension<ScheduledExecutorService> EXECUTOR_EXTENSION = ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java: ########## @@ -226,16 +228,20 @@ public void testCloseClientBeforeRequest() throws Exception { EmptyMessageParameters.getInstance(), EmptyRequestBody.getInstance()); - FlinkAssertions.assertThatFuture(future) - .eventuallyFailsWith(ExecutionException.class) + // Call get() on the future with a timeout of 0s so we can test that the exception + // thrown is not a TimeoutException, which is what would be thrown if restClient were + // not already closed + assertThatFuture(future) + .isCompletedExceptionally() + .failsWithin(0, TimeUnit.SECONDS) + .withThrowableOfType(ExecutionException.class) .withCauseInstanceOf(IllegalStateException.class) - .extracting(Throwable::getCause, as(THROWABLE)) - .hasMessage("RestClient is already closed"); + .withMessageContaining("RestClient is already closed"); Review Comment: Can be short here? ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java: ########## @@ -151,23 +145,27 @@ public void testConnectionClosedHandling() throws Exception { connectionSocket.close(); } - FlinkAssertions.assertThatFuture(responseFuture) - .eventuallyFailsWith(ExecutionException.class) - .withCauseInstanceOf(IOException.class); + try { + responseFuture.get(); + } catch (ExecutionException ee) { + if (!ExceptionUtils.findThrowable(ee, IOException.class).isPresent()) { + throw ee; + } + } Review Comment: Why we made this change? The old code is better to me. ```java assertThatFuture(responseFuture) .eventuallyFailsWith(ExecutionException.class) .withCauseInstanceOf(IOException.class); ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestExternalHandlersITCase.java: ########## @@ -128,30 +124,23 @@ void teardown() throws Exception { void testHandlersMustBeLoaded() { final List<InboundChannelHandlerFactory> inboundChannelHandlerFactories = serverEndpoint.getInboundChannelHandlerFactories(); - assertEquals(inboundChannelHandlerFactories.size(), 2); - assertTrue( - inboundChannelHandlerFactories.get(0) instanceof Prio1InboundChannelHandlerFactory); - assertTrue( - inboundChannelHandlerFactories.get(1) instanceof Prio0InboundChannelHandlerFactory); + assertThat(inboundChannelHandlerFactories.size()).isEqualTo(2); + assertThat(inboundChannelHandlerFactories.get(0)) + .isInstanceOf(Prio1InboundChannelHandlerFactory.class); + assertThat(inboundChannelHandlerFactories.get(1)) + .isInstanceOf(Prio0InboundChannelHandlerFactory.class); final List<OutboundChannelHandlerFactory> outboundChannelHandlerFactories = restClient.getOutboundChannelHandlerFactories(); - assertEquals(outboundChannelHandlerFactories.size(), 2); - assertTrue( - outboundChannelHandlerFactories.get(0) - instanceof Prio1OutboundChannelHandlerFactory); - assertTrue( - outboundChannelHandlerFactories.get(1) - instanceof Prio0OutboundChannelHandlerFactory); - - try { - final CompletableFuture<TestResponse> response = - sendRequestToTestHandler(new TestRequest()); - response.get(); - fail("Request must fail with 2 times redirected URL"); - } catch (Exception e) { - assertTrue(e.getMessage().contains(REDIRECT2_URL)); - } + assertThat(outboundChannelHandlerFactories.size()).isEqualTo(2); Review Comment: ```suggestion assertThat(outboundChannelHandlerFactories).hasSize(2); ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/FileUploadsTest.java: ########## @@ -68,47 +61,47 @@ public void testDirectoryScan() throws IOException { .map(File::toPath) .collect(Collectors.toList()); - Assert.assertEquals(2, detectedFiles.size()); - Assert.assertTrue(detectedFiles.contains(tmp.resolve(rootFile))); - Assert.assertTrue(detectedFiles.contains(tmp.resolve(subFile))); + assertThat(detectedFiles).hasSize(2); + assertThat(detectedFiles.contains(tmp.resolve(rootFile))).isTrue(); + assertThat(detectedFiles.contains(tmp.resolve(subFile))).isTrue(); Review Comment: ```suggestion assertThat(detectedFiles).contains(tmp.resolve(rootFile), tmp.resolve(subFile)) ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/InFlightRequestTrackerTest.java: ########## @@ -18,70 +18,65 @@ package org.apache.flink.runtime.rest.handler; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.concurrent.CompletableFuture; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; /** Tests for {@link InFlightRequestTracker}. */ -public class InFlightRequestTrackerTest { +class InFlightRequestTrackerTest { private InFlightRequestTracker inFlightRequestTracker; - @Before - public void setUp() { + @BeforeEach + void setUp() { inFlightRequestTracker = new InFlightRequestTracker(); } @Test - public void testShouldFinishAwaitAsyncImmediatelyIfNoRequests() { - assertTrue(inFlightRequestTracker.awaitAsync().isDone()); + void testShouldFinishAwaitAsyncImmediatelyIfNoRequests() { + assertThat(inFlightRequestTracker.awaitAsync()).isDone(); } @Test - public void testShouldFinishAwaitAsyncIffAllRequestsDeregistered() { + void testShouldFinishAwaitAsyncIffAllRequestsDeregistered() { inFlightRequestTracker.registerRequest(); final CompletableFuture<Void> awaitFuture = inFlightRequestTracker.awaitAsync(); - assertFalse(awaitFuture.isDone()); + assertThat(awaitFuture).isNotDone(); inFlightRequestTracker.deregisterRequest(); - assertTrue(awaitFuture.isDone()); + assertThat(awaitFuture).isDone(); } @Test - public void testAwaitAsyncIsIdempotent() { + void testAwaitAsyncIsIdempotent() { final CompletableFuture<Void> awaitFuture = inFlightRequestTracker.awaitAsync(); - assertTrue(awaitFuture.isDone()); - - assertSame( - "The reference to the future must not change", - awaitFuture, - inFlightRequestTracker.awaitAsync()); + assertThat(awaitFuture).isDone(); + assertThat(awaitFuture) + .as("The reference to the future must not change") + .isEqualTo(inFlightRequestTracker.awaitAsync()); Review Comment: ```suggestion assertThatFuture(awaitFuture) .as("The reference to the future must not change") .isCompletedWithValue(inFlightRequestTracker.awaitAsync()); ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerSSLAuthITCase.java: ########## @@ -130,7 +130,8 @@ public void testConnectFailure() throws Exception { fail("should never complete normally"); } catch (ExecutionException exception) { // that is what we want - assertTrue(ExceptionUtils.findThrowable(exception, SSLException.class).isPresent()); + assertThat(ExceptionUtils.findThrowable(exception, SSLException.class).isPresent()) + .isTrue(); Review Comment: ```suggestion assertThat(ExceptionUtils.findThrowable(exception, SSLException.class)).isPresent(); ``` But I prefer `assertThatFuture` as well. ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/FileUploadsTest.java: ########## @@ -33,30 +29,27 @@ import java.util.Collection; import java.util.stream.Collectors; -/** Tests for {@link FileUploads}. */ -public class FileUploadsTest extends TestLogger { +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; - @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); +/** Tests for {@link FileUploads}. */ +class FileUploadsTest { @Test - public void testRelativePathRejection() throws IOException { + void testRelativePathRejection() throws IOException { Path relative = Paths.get("root"); - try { - new FileUploads(relative); - Assert.fail(); - } catch (IllegalArgumentException iae) { - // expected - } + assertThatThrownBy(() -> new FileUploads(relative)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void testDirectoryScan() throws IOException { + void testDirectoryScan(@TempDir File temporaryFolder) throws IOException { Review Comment: How about declare `@TempDir` as class private property. ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/InFlightRequestTrackerTest.java: ########## @@ -18,70 +18,65 @@ package org.apache.flink.runtime.rest.handler; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.concurrent.CompletableFuture; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; /** Tests for {@link InFlightRequestTracker}. */ -public class InFlightRequestTrackerTest { +class InFlightRequestTrackerTest { private InFlightRequestTracker inFlightRequestTracker; - @Before - public void setUp() { + @BeforeEach + void setUp() { inFlightRequestTracker = new InFlightRequestTracker(); } @Test - public void testShouldFinishAwaitAsyncImmediatelyIfNoRequests() { - assertTrue(inFlightRequestTracker.awaitAsync().isDone()); + void testShouldFinishAwaitAsyncImmediatelyIfNoRequests() { + assertThat(inFlightRequestTracker.awaitAsync()).isDone(); } @Test - public void testShouldFinishAwaitAsyncIffAllRequestsDeregistered() { + void testShouldFinishAwaitAsyncIffAllRequestsDeregistered() { inFlightRequestTracker.registerRequest(); final CompletableFuture<Void> awaitFuture = inFlightRequestTracker.awaitAsync(); - assertFalse(awaitFuture.isDone()); + assertThat(awaitFuture).isNotDone(); inFlightRequestTracker.deregisterRequest(); - assertTrue(awaitFuture.isDone()); + assertThat(awaitFuture).isDone(); } @Test - public void testAwaitAsyncIsIdempotent() { + void testAwaitAsyncIsIdempotent() { final CompletableFuture<Void> awaitFuture = inFlightRequestTracker.awaitAsync(); - assertTrue(awaitFuture.isDone()); - - assertSame( - "The reference to the future must not change", - awaitFuture, - inFlightRequestTracker.awaitAsync()); + assertThat(awaitFuture).isDone(); + assertThat(awaitFuture) + .as("The reference to the future must not change") + .isEqualTo(inFlightRequestTracker.awaitAsync()); } @Test - public void testShouldTolerateRegisterAfterAwaitAsync() { + void testShouldTolerateRegisterAfterAwaitAsync() { final CompletableFuture<Void> awaitFuture = inFlightRequestTracker.awaitAsync(); - assertTrue(awaitFuture.isDone()); + assertThat(awaitFuture).isDone(); inFlightRequestTracker.registerRequest(); - assertSame( - "The reference to the future must not change", - awaitFuture, - inFlightRequestTracker.awaitAsync()); + assertThat(awaitFuture) + .as("The reference to the future must not change") + .isEqualTo(inFlightRequestTracker.awaitAsync()); Review Comment: ```suggestion .isSameAs(inFlightRequestTracker.awaitAsync()); ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/JobSubmitHandlerTest.java: ########## @@ -320,7 +324,7 @@ public void testFailedJobSubmission() throws Exception { .get(); } catch (Exception e) { Throwable t = ExceptionUtils.stripExecutionException(e); - Assert.assertEquals(errorMessage, t.getMessage()); + assertThat(t.getMessage()).isEqualTo(errorMessage); Review Comment: How about `assertThatThrownBy` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/cluster/JobManagerCustomLogHandlerTest.java: ########## @@ -105,60 +96,60 @@ private static HandlerRequest<EmptyRequestBody> createHandlerRequest(String path } @Test - public void testGetJobManagerCustomLogsValidFilename() throws Exception { + void testGetJobManagerCustomLogsValidFilename() throws Exception { File actualFile = testInstance.getFile(createHandlerRequest(VALID_LOG_FILENAME)); - assertThat(actualFile, is(notNullValue())); + assertThat(actualFile).isNotNull(); String actualContent = String.join("", Files.readAllLines(actualFile.toPath())); - assertThat(actualContent, is(VALID_LOG_CONTENT)); + assertThat(actualContent).isEqualTo(VALID_LOG_CONTENT); } @Test - public void testGetJobManagerCustomLogsValidFilenameWithPath() throws Exception { + void testGetJobManagerCustomLogsValidFilenameWithPath() throws Exception { File actualFile = testInstance.getFile( createHandlerRequest(String.format("foobar/%s", VALID_LOG_FILENAME))); - assertThat(actualFile, is(notNullValue())); + assertThat(actualFile).isNotNull(); String actualContent = String.join("", Files.readAllLines(actualFile.toPath())); - assertThat(actualContent, is(VALID_LOG_CONTENT)); + assertThat(actualContent).isEqualTo(VALID_LOG_CONTENT); } @Test - public void testGetJobManagerCustomLogsValidFilenameWithInvalidPath() throws Exception { + void testGetJobManagerCustomLogsValidFilenameWithInvalidPath() throws Exception { File actualFile = testInstance.getFile( createHandlerRequest(String.format("../%s", VALID_LOG_FILENAME))); - assertThat(actualFile, is(notNullValue())); + assertThat(actualFile).isNotNull(); String actualContent = String.join("", Files.readAllLines(actualFile.toPath())); - assertThat(actualContent, is(VALID_LOG_CONTENT)); + assertThat(actualContent).isEqualTo(VALID_LOG_CONTENT); } @Test - public void testGetJobManagerCustomLogsNotExistingFile() throws Exception { + void testGetJobManagerCustomLogsNotExistingFile() throws Exception { File actualFile = testInstance.getFile(createHandlerRequest("not-existing")); - assertThat(actualFile, is(notNullValue())); - assertFalse(actualFile.exists()); + assertThat(actualFile).isNotNull(); + assertThat(actualFile.exists()).isFalse(); } @Test - public void testGetJobManagerCustomLogsExistingButForbiddenFile() throws Exception { + void testGetJobManagerCustomLogsExistingButForbiddenFile() throws Exception { File actualFile = testInstance.getFile( createHandlerRequest(String.format("../%s", FORBIDDEN_FILENAME))); - assertThat(actualFile, is(notNullValue())); - assertFalse(actualFile.exists()); + assertThat(actualFile).isNotNull(); + assertThat(actualFile.exists()).isFalse(); Review Comment: ```suggestion assertThat(actualFile).isNotNull().exists(); ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/cluster/JobManagerLogListHandlerTest.java: ########## @@ -91,18 +83,17 @@ public void testGetJobManagerLogsList() throws Exception { LogListInfo logListInfo = jobManagerLogListHandler.handleRequest(testRequest, dispatcherGateway).get(); - assertThat( - logListInfo.getLogInfos(), - containsInAnyOrder(expectedLogInfo.toArray(new LogInfo[0]))); + assertThat(logListInfo.getLogInfos()) + .containsExactlyInAnyOrder(expectedLogInfo.toArray(new LogInfo[0])); Review Comment: ```suggestion .containsExactlyInAnyOrderElementsOf(expectedLogInfo); ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java: ########## @@ -340,60 +331,52 @@ public void testBadHandlerRequest() throws Exception { } catch (ExecutionException ee) { Throwable t = ExceptionUtils.stripExecutionException(ee); - assertTrue(t instanceof RestClientException); + assertThat(t instanceof RestClientException).isTrue(); RestClientException rce = (RestClientException) t; - assertEquals(HttpResponseStatus.BAD_REQUEST, rce.getHttpResponseStatus()); + assertThat(rce.getHttpResponseStatus()).isEqualTo(HttpResponseStatus.BAD_REQUEST); Review Comment: Hi @wangzzu. I think we can use ```java assertThatFuture(response) .eventuallyFailsWith(ExecutionException.class) .havingCause() .isInstanceOf(RestClientException.class) .satisfies( e -> Assertions.assertThat( ((RestClientException) e).getHttpResponseStatus()) .isSameAs(HttpResponseStatus.BAD_REQUEST)); ``` -- 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