guozhangwang commented on code in PR #12466: URL: https://github.com/apache/kafka/pull/12466#discussion_r946148995
########## streams/src/test/java/org/apache/kafka/streams/processor/internals/TaskManagerTest.java: ########## @@ -296,6 +296,75 @@ public void shouldAddTasksToStateUpdater() { Mockito.verify(stateUpdater).add(task01); } + @Test + public void shouldHandleRemovedTasksFromStateUpdater() { + // tasks to recycle + final StreamTask task00 = mock(StreamTask.class); + final StandbyTask task01 = mock(StandbyTask.class); + final StandbyTask task00Converted = mock(StandbyTask.class); + final StreamTask task01Converted = mock(StreamTask.class); + // task to close + final StreamTask task02 = mock(StreamTask.class); + // task to update inputs + final StreamTask task03 = mock(StreamTask.class); + when(task00.id()).thenReturn(taskId00); + when(task01.id()).thenReturn(taskId01); + when(task02.id()).thenReturn(taskId02); + when(task03.id()).thenReturn(taskId03); + when(task00.inputPartitions()).thenReturn(taskId00Partitions); + when(task01.inputPartitions()).thenReturn(taskId01Partitions); + when(task02.inputPartitions()).thenReturn(taskId02Partitions); + when(task03.inputPartitions()).thenReturn(taskId03Partitions); + when(task00.isActive()).thenReturn(true); + when(task01.isActive()).thenReturn(false); + when(task02.isActive()).thenReturn(true); + when(task03.isActive()).thenReturn(true); + when(task00.state()).thenReturn(State.RESTORING); + when(task01.state()).thenReturn(State.RUNNING); + when(task02.state()).thenReturn(State.RESTORING); + when(task03.state()).thenReturn(State.RESTORING); + when(stateUpdater.drainRemovedTasks()).thenReturn(mkSet(task00, task01, task02, task03)); + + expect(activeTaskCreator.createActiveTaskFromStandby(eq(task01), eq(taskId01Partitions), eq(consumer))) + .andStubReturn(task01Converted); + activeTaskCreator.closeAndRemoveTaskProducerIfNeeded(anyObject()); + expectLastCall().times(2); + expect(standbyTaskCreator.createStandbyTaskFromActive(eq(task00), eq(taskId00Partitions))) + .andStubReturn(task00Converted); + expect(consumer.assignment()).andReturn(emptySet()).anyTimes(); + consumer.resume(anyObject()); + expectLastCall().anyTimes(); + replay(activeTaskCreator, standbyTaskCreator, topologyBuilder, consumer); Review Comment: Yes.. I tried to use Mockito for all and soon realized it would incur a much larger scope. -- 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