[GitHub] [kafka] cadonna commented on a diff in pull request #13712: KAFKA-14133: Migrate Admin mock in TaskManagerTest to Mockito

2023-06-08 Thread via GitHub


cadonna commented on code in PR #13712:
URL: https://github.com/apache/kafka/pull/13712#discussion_r1222986401


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/TaskManagerTest.java:
##
@@ -3694,12 +3694,12 @@ public Map 
prepareCommit() {
 
 @Test
 public void shouldSendPurgeData() {
-resetToStrict(adminClient);
-expect(adminClient.deleteRecords(singletonMap(t1p1, 
RecordsToDelete.beforeOffset(5L
-.andReturn(new DeleteRecordsResult(singletonMap(t1p1, 
completedFuture(;
-expect(adminClient.deleteRecords(singletonMap(t1p1, 
RecordsToDelete.beforeOffset(17L
-.andReturn(new DeleteRecordsResult(singletonMap(t1p1, 
completedFuture(;
-replay(adminClient);
+when(adminClient.deleteRecords(singletonMap(t1p1, 
RecordsToDelete.beforeOffset(5L
+.thenReturn(new DeleteRecordsResult(singletonMap(t1p1, 
completedFuture(;
+when(adminClient.deleteRecords(singletonMap(t1p1, 
RecordsToDelete.beforeOffset(17L
+.thenReturn(new DeleteRecordsResult(singletonMap(t1p1, 
completedFuture(;
+
+InOrder inOrder = Mockito.inOrder(adminClient);

Review Comment:
   ```suggestion
   final InOrder inOrder = Mockito.inOrder(adminClient);
   ```



-- 
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



[GitHub] [kafka] cadonna commented on a diff in pull request #13712: KAFKA-14133: Migrate Admin mock in TaskManagerTest to Mockito

2023-06-06 Thread via GitHub


cadonna commented on code in PR #13712:
URL: https://github.com/apache/kafka/pull/13712#discussion_r1219140005


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/TaskManagerTest.java:
##
@@ -3747,12 +3748,10 @@ public Map 
prepareCommit() {
 
 @Test
 public void shouldSendPurgeData() {
-resetToStrict(adminClient);
-expect(adminClient.deleteRecords(singletonMap(t1p1, 
RecordsToDelete.beforeOffset(5L
-.andReturn(new DeleteRecordsResult(singletonMap(t1p1, 
completedFuture(;
-expect(adminClient.deleteRecords(singletonMap(t1p1, 
RecordsToDelete.beforeOffset(17L
-.andReturn(new DeleteRecordsResult(singletonMap(t1p1, 
completedFuture(;
-replay(adminClient);
+when(adminClient.deleteRecords(singletonMap(t1p1, 
RecordsToDelete.beforeOffset(5L
+.thenReturn(new DeleteRecordsResult(singletonMap(t1p1, 
completedFuture(;
+when(adminClient.deleteRecords(singletonMap(t1p1, 
RecordsToDelete.beforeOffset(17L
+.thenReturn(new DeleteRecordsResult(singletonMap(t1p1, 
completedFuture(;

Review Comment:
   I think you need to verify the order of the calls since the admin mock is 
reset to strict in EasyMock. The order is indeed important here because you do 
not want to purge records in the wrong order from a repartition topic.



-- 
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