C0urante commented on code in PR #12735:
URL: https://github.com/apache/kafka/pull/12735#discussion_r1020486952
##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/ErrorHandlingTaskTest.java:
##########
@@ -176,18 +180,15 @@ public class ErrorHandlingTaskTest {
private WorkerErrantRecordReporter workerErrantRecordReporter;
private ErrorHandlingMetrics errorHandlingMetrics;
-
private boolean enableTopicCreation;
-
- @ParameterizedTest.Parameters
+ @Parameterized.Parameters
public static Collection<Boolean> parameters() {
return Arrays.asList(false, true);
}
public ErrorHandlingTaskTest(boolean enableTopicCreation) {
this.enableTopicCreation = enableTopicCreation;
}
-
Review Comment:
Can we revert this unnecessary whitespace change?
##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/ErrorHandlingTaskTest.java:
##########
@@ -176,18 +180,15 @@ public class ErrorHandlingTaskTest {
private WorkerErrantRecordReporter workerErrantRecordReporter;
private ErrorHandlingMetrics errorHandlingMetrics;
-
Review Comment:
Can we revert this unnecessary whitespace change?
##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/ErrorHandlingTaskTest.java:
##########
@@ -176,18 +180,15 @@ public class ErrorHandlingTaskTest {
private WorkerErrantRecordReporter workerErrantRecordReporter;
private ErrorHandlingMetrics errorHandlingMetrics;
-
private boolean enableTopicCreation;
-
Review Comment:
Can we revert this unnecessary whitespace change?
##########
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:
We're not using EasyMock anymore, so we don't have to issue the same calls.
They also have a different meaning when using EasyMock, where you have to
invoke `void` methods and then `expectLastCall` during the setup phase before
replaying the mock.
--
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]