cadonna commented on code in PR #12524: URL: https://github.com/apache/kafka/pull/12524#discussion_r997292607
########## streams/src/test/java/org/apache/kafka/streams/processor/internals/StandbyTaskTest.java: ########## @@ -313,36 +282,29 @@ public void shouldNotFlushAndThrowOnCloseDirty() { final double expectedCloseTaskMetric = 1.0; verifyCloseTaskMetric(expectedCloseTaskMetric, streamsMetrics, metricName); - - EasyMock.verify(stateManager); } @Test public void shouldNotThrowFromStateManagerCloseInCloseDirty() { - EasyMock.expect(stateManager.changelogOffsets()).andStubReturn(Collections.emptyMap()); - stateManager.close(); - EasyMock.expectLastCall().andThrow(new RuntimeException("KABOOM!")).anyTimes(); - EasyMock.replay(stateManager); + doThrow(new RuntimeException("KABOOM!")).when(stateManager).close(); task = createStandbyTask(); task.initializeIfNeeded(); task.suspend(); task.closeDirty(); - EasyMock.verify(stateManager); + verify(stateManager, atLeastOnce()).close(); } @Test public void shouldSuspendAndCommitBeforeCloseClean() { stateManager.close(); - EasyMock.expectLastCall(); + verify(stateManager, atLeastOnce()).close(); stateManager.checkpoint(); Review Comment: Yes, I am looking at the latest commit. I added some inline comments to the code you posted. ```java @Test public void shouldSuspendAndCommitBeforeCloseClean() { when(stateManager.changelogOffsets()) .thenReturn(Collections.singletonMap(partition, 60L)); final InOrder stateManagerOrdered = inOrder(stateManager); stateManager.close(); // <- This is a call directly on the mock. // With EasyMock that is the way to specify expected calls on a mock. // With Mockito you must not do this. // With Mockito you verify the expected calls at the end with Mockito.verify(). stateManager.checkpoint(); // <- This is also a direct call on the mock. // The same applies as above stateManagerOrdered.verify(stateManager, times(1)).checkpoint(); // <- This is always true // if you make the call stateManager.close() above. when(stateManager.changelogOffsets()) .thenReturn(Collections.singletonMap(partition, 60L)); final MetricName metricName = setupCloseTaskMetric(); task = createStandbyTask(); task.initializeIfNeeded(); task.suspend(); task.prepareCommit(); task.postCommit(true); // <- this should call stateManager.checkpoint() internally. task.closeClean(); // <- this should call stateManager.close() internally // Those internal calls are the ones that need to be verified. assertEquals(Task.State.CLOSED, task.state()); final double expectedCloseTaskMetric = 1.0; verifyCloseTaskMetric(expectedCloseTaskMetric, streamsMetrics, metricName); verify(stateManager).changelogOffsets(); stateManagerOrdered.verify(stateManager, atLeastOnce()).close(); } ``` -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org