You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/08/17 10:12:28 UTC

[GitHub] [kafka] mdedetrich commented on a diff in pull request #12524: KAFKA-14133: Replace EasyMock with Mockito in streams test

mdedetrich commented on code in PR #12524:
URL: https://github.com/apache/kafka/pull/12524#discussion_r947741172


##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamThreadTest.java:
##########
@@ -2912,34 +2872,34 @@ void runOnce() {
     }
 
     private TaskManager mockTaskManagerPurge(final int numberOfPurges) {
-        final TaskManager taskManager = EasyMock.createNiceMock(TaskManager.class);
+        final TaskManager taskManager = mock(TaskManager.class);
         final Task runningTask = mock(Task.class);
         final TaskId taskId = new TaskId(0, 0);
 
-        expect(runningTask.state()).andReturn(Task.State.RUNNING).anyTimes();
-        expect(runningTask.id()).andReturn(taskId).anyTimes();
-        expect(taskManager.allTasks())
-                .andReturn(Collections.singletonMap(taskId, runningTask)).anyTimes();
-        expect(taskManager.commit(Collections.singleton(runningTask))).andReturn(1).anyTimes();
-        taskManager.maybePurgeCommittedRecords();
-        EasyMock.expectLastCall().times(numberOfPurges);
-        EasyMock.replay(taskManager, runningTask);
+        when(runningTask.state()).thenReturn(Task.State.RUNNING);
+        when(runningTask.id()).thenReturn(taskId);
+        when(taskManager.allTasks())
+            .thenReturn(Collections.singletonMap(taskId, runningTask));
+        when(taskManager.commit(Collections.singleton(runningTask))).thenReturn(1);
+        for (int i = 0; i < numberOfPurges; i++) {

Review Comment:
   This for loop was added to actually simulate the number of purges that I assume the `mockTaskManagerPurge` is trying to emulate. Not sure how `EasyMock` did this but this version is more explicit and clear.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org