cadonna commented on code in PR #13529:
URL: https://github.com/apache/kafka/pull/13529#discussion_r1168432918
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/TaskManagerTest.java:
##########
@@ -970,6 +971,7 @@ public void
shouldHandleMultipleRemovedTasksFromStateUpdater() {
expectLastCall().anyTimes();
final TasksRegistry tasks = mock(TasksRegistry.class);
when(tasks.removePendingTaskToCloseClean(taskToClose.id())).thenReturn(true);
+ when(tasks.removePendingTaskToCloseClean(argThat(taskId ->
!taskId.equals(taskToClose.id())))).thenReturn(false);
Review Comment:
I had to add this since Mockito threw an error. The cause of the errors was
that this PR set the Mockito stubs to strict. The error was:
```
org.mockito.exceptions.misusing.PotentialStubbingProblem:
Strict stubbing argument mismatch. Please check:
- this invocation of 'removePendingTaskToCloseClean' method:
tasksRegistry.removePendingTaskToCloseClean(
0_3
);
-> at
org.apache.kafka.streams.processor.internals.TaskManager.handleRemovedTasksFromStateUpdater(TaskManager.java:876)
- has following stubbing(s) with different arguments:
1. tasksRegistry.removePendingTaskToCloseClean(
0_2
);
-> at
org.apache.kafka.streams.processor.internals.TaskManagerTest.shouldHandleMultipleRemovedTasksFromStateUpdater(TaskManagerTest.java:973)
Typically, stubbing argument mismatch indicates user mistake when writing
tests.
Mockito fails early so that you can debug potential problem easily.
However, there are legit scenarios when this exception generates false
negative signal:
- stubbing the same method multiple times using 'given().will()' or
'when().then()' API
Please use 'will().given()' or 'doReturn().when()' API for stubbing.
- stubbed method is intentionally invoked with different arguments by code
under test
Please use default or 'silent' JUnit Rule (equivalent of
Strictness.LENIENT).
For more information see javadoc for PotentialStubbingProblem class.
```
In this case, the code under test calls `removePendingTaskToCloseClean()`
multiple times with different arguments. That is normal but needs to be
considered in the unit test.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]