snuyanzin commented on code in PR #21368:
URL: https://github.com/apache/flink/pull/21368#discussion_r1031164160


##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateChunkReaderTest.java:
##########
@@ -35,31 +35,44 @@
 
 import static org.apache.flink.util.Preconditions.checkArgument;
 import static org.apache.flink.util.Preconditions.checkState;
-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;
+import static org.assertj.core.api.Assertions.fail;
 
 /** {@link ChannelStateChunkReader} test. */
-public class ChannelStateChunkReaderTest {
+class ChannelStateChunkReaderTest {
 
-    @Test(expected = TestException.class)
-    public void testBufferRecycledOnFailure() throws IOException, 
InterruptedException {
+    @Test
+    void testBufferRecycledOnFailure() {
         FailingChannelStateSerializer serializer = new 
FailingChannelStateSerializer();
         TestRecoveredChannelStateHandler handler = new 
TestRecoveredChannelStateHandler();
 
-        try (FSDataInputStream stream = getStream(serializer, 10)) {
-            new ChannelStateChunkReader(serializer)
-                    .readChunk(stream, serializer.getHeaderLength(), handler, 
"channelInfo", 0);
-        } finally {
-            checkState(serializer.failed);
-            checkState(!handler.requestedBuffers.isEmpty());
-            assertTrue(
-                    handler.requestedBuffers.stream()
-                            .allMatch(TestChannelStateByteBuffer::isRecycled));
-        }
+        assertThatThrownBy(
+                        () -> {
+                            try (FSDataInputStream stream = 
getStream(serializer, 10)) {
+                                new ChannelStateChunkReader(serializer)
+                                        .readChunk(
+                                                stream,
+                                                serializer.getHeaderLength(),
+                                                handler,
+                                                "channelInfo",
+                                                0);
+                            } finally {
+                                checkState(serializer.failed);
+                                
checkState(!handler.requestedBuffers.isEmpty());

Review Comment:
   ```suggestion
                                   assertThat(serializer.failed).isTrue();
                                   
assertThat(handler.requestedBuffers).isNotEmpty();
   ```
   It seems `checkState` could be replaced with `assertThat` since the latest 
gives a better message



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

Reply via email to