hgeraldino commented on code in PR #13191:
URL: https://github.com/apache/kafka/pull/13191#discussion_r1112464114


##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractWorkerSourceTaskTest.java:
##########
@@ -485,32 +479,45 @@ public void testSendRecordsTopicDescribeRetriesMidway() {
         SourceRecord record2 = new SourceRecord(PARTITION, OFFSET, TOPIC, 2, 
KEY_SCHEMA, KEY, RECORD_SCHEMA, RECORD);
         SourceRecord record3 = new SourceRecord(PARTITION, OFFSET, 
OTHER_TOPIC, 3, KEY_SCHEMA, KEY, RECORD_SCHEMA, RECORD);
 
-        // First round
-        expectPreliminaryCalls(OTHER_TOPIC);
-        expectTopicCreation(TOPIC);
-        expectSendRecord();
-        expectSendRecord();
-
-        // First call to describe the topic times out
-        EasyMock.expect(admin.describeTopics(OTHER_TOPIC))
-                .andThrow(new RetriableException(new 
TimeoutException("timeout")));
+        expectPreliminaryCalls();
 
-        // Second round
-        expectTopicCreation(OTHER_TOPIC);
-        expectSendRecord(OTHER_TOPIC, false, emptyHeaders());
+        when(admin.describeTopics(anyString())).thenAnswer(new 
Answer<Map<String, TopicDescription>>() {
+            int counter = 0;
 
-        PowerMock.replayAll();
+            @Override
+            public Map<String, TopicDescription> answer(InvocationOnMock 
invocation) {
+                counter++;
+                if (counter == 2) {
+                    throw new RetriableException(new 
TimeoutException("timeout"));
+                }
 
-        // Try to send 3, make first pass, second fail. Should save last two
+                return Collections.emptyMap();
+            }
+        });

Review Comment:
   It certainly is more readable. 
   
   Fixed



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