shekhar-rajak commented on code in PR #12735:
URL: https://github.com/apache/kafka/pull/12735#discussion_r1018066045


##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/ErrorHandlingTaskTest.java:
##########
@@ -374,30 +350,40 @@ public void testErrorHandlingInSourceTasks() throws 
Exception {
         Struct struct2 = new Struct(valSchema).put("val", 6789);
         SourceRecord record2 = new SourceRecord(emptyMap(), emptyMap(), TOPIC, 
PARTITION1, valSchema, struct2);
 
-        EasyMock.expect(workerSourceTask.isStopping()).andReturn(false);
-        EasyMock.expect(workerSourceTask.isStopping()).andReturn(false);
-        EasyMock.expect(workerSourceTask.isStopping()).andReturn(true);
+        when(workerSourceTask.isStopping())
+                .thenReturn(false)
+                .thenReturn(false)
+                .thenReturn(true);
 
-        EasyMock.expect(workerSourceTask.commitOffsets()).andReturn(true);
+        doReturn(true).when(workerSourceTask).commitOffsets();
 
-        offsetStore.start();
-        EasyMock.expectLastCall();
-        sourceTask.initialize(EasyMock.anyObject());
-        EasyMock.expectLastCall();
-        sourceTask.start(EasyMock.anyObject());
-        EasyMock.expectLastCall();
+        when(sourceTask.poll())
+                .thenReturn(singletonList(record1))
+                .thenReturn(singletonList(record2));
 
-        EasyMock.expect(sourceTask.poll()).andReturn(singletonList(record1));
-        EasyMock.expect(sourceTask.poll()).andReturn(singletonList(record2));
         expectTopicCreation(TOPIC);
-        EasyMock.expect(producer.send(EasyMock.anyObject(), 
EasyMock.anyObject())).andReturn(null).times(2);
 
-        PowerMock.replayAll();
+        when(producer.send(any(), any()))
+                .thenReturn(null)
+                .thenReturn(null);
 
         workerSourceTask.initialize(TASK_CONFIG);
         workerSourceTask.initializeAndStart();
         workerSourceTask.execute();
 
+        verify(workerSourceTask, times(3)).isStopping();
+        verify(workerSourceTask).commitOffsets();
+
+        verify(offsetStore).start();
+
+        verify(sourceTask).initialize(any());
+        verify(sourceTask).start(any());
+
+        verify(sourceTask, times(2)).poll();
+
+        verify(producer, times(2)).send(any(), any());
+        assertEquals(null, producer.send(any()));

Review Comment:
   This all added since previously  there was bunch of 
`EasyMock.expectLastCall();` doing the same. 



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

Reply via email to