yashmayya commented on code in PR #12615:
URL: https://github.com/apache/kafka/pull/12615#discussion_r970342294


##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/errors/RetryWithToleranceOperatorTest.java:
##########
@@ -222,25 +224,31 @@ public void 
testExecAndHandleRetriableErrorWithMaxRetriesExceeded() throws Excep
 
     public void execAndHandleRetriableError(long errorRetryTimeout, int 
numRetriableExceptionsThrown, List<Long> expectedWaits, Exception e, boolean 
successExpected) throws Exception {
         MockTime time = new MockTime(0, 0, 0);
-        CountDownLatch exitLatch = 
PowerMock.createStrictMock(CountDownLatch.class);
+        CountDownLatch exitLatch = mock(CountDownLatch.class);
         RetryWithToleranceOperator retryWithToleranceOperator = new 
RetryWithToleranceOperator(errorRetryTimeout, ERRORS_RETRY_MAX_DELAY_DEFAULT, 
ALL, time, new ProcessingContext(), exitLatch);
         retryWithToleranceOperator.metrics(errorHandlingMetrics);
 
-        
EasyMock.expect(mockOperation.call()).andThrow(e).times(numRetriableExceptionsThrown);
-
-        if (successExpected) {
-            EasyMock.expect(mockOperation.call()).andReturn("Success");
-        }
+        when(mockOperation.call()).thenAnswer(new Answer<String>() {
+            private int count = 0;
+
+            @Override
+            public String answer(InvocationOnMock invocation) throws Throwable 
{
+                if (count++ != numRetriableExceptionsThrown) {
+                    throw e;
+                } else if (successExpected) {
+                    return "Success";
+                }
+                return null;
+            }
+        });

Review Comment:
   Ah neat, I hadn't considered doing it this way. It does look cleaner 👍 



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