fredia commented on code in PR #22457: URL: https://github.com/apache/flink/pull/22457#discussion_r1187096060
########## flink-queryable-state/flink-queryable-state-runtime/src/test/java/org/apache/flink/queryablestate/network/KvStateClientHandlerTest.java: ########## @@ -93,28 +92,66 @@ public void testReadCallbacksAndBufferRecycling() throws Exception { // Verify callback channel.writeInbound(buf); - verify(callback, times(1)).onFailure(isA(RuntimeException.class)); + assertThat(TestClientHandlerCallback.onFailureCnt).isEqualTo(1); + assertThat(TestClientHandlerCallback.onFailureBody).isInstanceOf(RuntimeException.class); // // Unexpected messages // buf = channel.alloc().buffer(4).writeInt(1223823); // Verify callback + TestClientHandlerCallback.onFailureCnt = 0; channel.writeInbound(buf); - verify(callback, times(1)).onFailure(isA(IllegalStateException.class)); - assertEquals("Buffer not recycled", 0, buf.refCnt()); + assertThat(TestClientHandlerCallback.onFailureCnt).isEqualTo(1); + assertThat(TestClientHandlerCallback.onFailureBody).isInstanceOf(RuntimeException.class); + assertThat(buf.refCnt()).isEqualTo(0).withFailMessage("Buffer not recycled"); // // Exception caught // + TestClientHandlerCallback.onFailureCnt = 0; channel.pipeline().fireExceptionCaught(new RuntimeException("Expected test Exception")); - verify(callback, times(3)).onFailure(isA(RuntimeException.class)); + assertThat(TestClientHandlerCallback.onFailureCnt).isEqualTo(1); + assertThat(TestClientHandlerCallback.onFailureBody).isInstanceOf(RuntimeException.class); // // Channel inactive // + TestClientHandlerCallback.onFailureCnt = 0; channel.pipeline().fireChannelInactive(); - verify(callback, times(1)).onFailure(isA(ClosedChannelException.class)); + assertThat(TestClientHandlerCallback.onFailureCnt).isEqualTo(1); + assertThat(TestClientHandlerCallback.onFailureBody).isInstanceOf(ClosedChannelException.class); + } + + private static class TestClientHandlerCallback implements ClientHandlerCallback { + private static int onRequestCnt; Review Comment: For more convenient access to those fields from external classes, something like: ```Java assertThat(TestingClientHandlerCallback.onRequestCnt).isEqualTo(1); assertThat(TestingClientHandlerCallback.onRequestId).isEqualTo(1222112277L); assertThat(TestingClientHandlerCallback.onRequestBody).isInstanceOf(KvStateResponse.class); ``` -- 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