yashmayya commented on code in PR #12615: URL: https://github.com/apache/kafka/pull/12615#discussion_r970342727
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/errors/WorkerErrantRecordReporterTest.java: ########## @@ -78,4 +68,41 @@ public void testGetFutures() { reporter.awaitFutures(topicPartitions); assertTrue(reporter.futures.isEmpty()); } + + @Test + public void testReport() { + initializeReporter(true); + when(errorReporter.report(any())).thenReturn(CompletableFuture.completedFuture(null)); + @SuppressWarnings("unchecked") ConsumerRecord<byte[], byte[]> consumerRecord = mock(ConsumerRecord.class); + when(record.originalRecord()).thenReturn(consumerRecord); + reporter.report(record, new Throwable()); + verify(errorReporter).report(any()); + } + + @Test + public void testReportNoToleratedErrors() { + initializeReporter(false); + when(errorReporter.report(any())).thenReturn(CompletableFuture.completedFuture(null)); + @SuppressWarnings("unchecked") ConsumerRecord<byte[], byte[]> consumerRecord = mock(ConsumerRecord.class); + when(record.originalRecord()).thenReturn(consumerRecord); + assertThrows(ConnectException.class, () -> reporter.report(record, new Throwable())); + verify(errorReporter).report(any()); + } + + private void initializeReporter(boolean errorsTolerated) { + retryWithToleranceOperator = new RetryWithToleranceOperator( + 5000, + ConnectorConfig.ERRORS_RETRY_MAX_DELAY_DEFAULT, + errorsTolerated ? ToleranceType.ALL : ToleranceType.NONE, + Time.SYSTEM + ); + retryWithToleranceOperator.reporters(Collections.singletonList(errorReporter)); + retryWithToleranceOperator.metrics(mock(ErrorHandlingMetrics.class)); Review Comment: Yeah fair enough, that stuck out as being a little odd to me too. I've made the changes. -- 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