snuyanzin commented on code in PR #21368: URL: https://github.com/apache/flink/pull/21368#discussion_r1031199977
########## flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriterImplTest.java: ########## @@ -37,51 +37,58 @@ import static org.apache.flink.runtime.state.ChannelPersistenceITCase.getStreamFactoryFactory; import static org.apache.flink.util.CloseableIterator.ofElements; import static org.apache.flink.util.ExceptionUtils.findThrowable; -import static org.junit.Assert.assertFalse; -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 ChannelStateWriterImpl} lifecycle tests. */ -public class ChannelStateWriterImplTest { +class ChannelStateWriterImplTest { private static final long CHECKPOINT_ID = 42L; private static final String TASK_NAME = "test"; - @Test(expected = IllegalArgumentException.class) - public void testAddEventBuffer() throws Exception { + @Test + void testAddEventBuffer() { NetworkBuffer dataBuf = getBuffer(); NetworkBuffer eventBuf = getBuffer(); eventBuf.setDataType(Buffer.DataType.EVENT_BUFFER); - try { - runWithSyncWorker( - writer -> { - callStart(writer); - writer.addInputData( - CHECKPOINT_ID, - new InputChannelInfo(1, 1), - 1, - ofElements(Buffer::recycleBuffer, eventBuf, dataBuf)); - }); - } finally { - assertTrue(dataBuf.isRecycled()); - } + assertThatThrownBy( + () -> { + try { + runWithSyncWorker( + writer -> { + callStart(writer); + writer.addInputData( + CHECKPOINT_ID, + new InputChannelInfo(1, 1), + 1, + ofElements( + Buffer::recycleBuffer, + eventBuf, + dataBuf)); + }); + } finally { + assertThat(dataBuf.isRecycled()).isTrue(); + } + }) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void testResultCompletion() throws IOException { + void testResultCompletion() throws IOException { ChannelStateWriteResult result; try (ChannelStateWriterImpl writer = openWriter()) { callStart(writer); result = writer.getAndRemoveWriteResult(CHECKPOINT_ID); - assertFalse(result.resultSubpartitionStateHandles.isDone()); - assertFalse(result.inputChannelStateHandles.isDone()); + assertThat(result.resultSubpartitionStateHandles.isDone()).isFalse(); + assertThat(result.inputChannelStateHandles.isDone()).isFalse(); } - assertTrue(result.inputChannelStateHandles.isDone()); - assertTrue(result.resultSubpartitionStateHandles.isDone()); + assertThat(result.inputChannelStateHandles.isDone()).isTrue(); + assertThat(result.resultSubpartitionStateHandles.isDone()).isTrue(); Review Comment: ```suggestion assertThat(result.inputChannelStateHandles).isDone(); assertThat(result.resultSubpartitionStateHandles).isDone(); ``` assertJ supports some `CompletableFuture` methods -- 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