loicgreffier commented on code in PR #16433:
URL: https://github.com/apache/kafka/pull/16433#discussion_r1688203643
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/RecordCollectorTest.java:
##########
@@ -1705,4 +1742,70 @@ public byte[] serialize(final String topic, final
Headers headers, final String
return serialize(topic, data);
}
}
+
+ public static class ProductionExceptionHandlerMock implements
ProductionExceptionHandler {
+ private final ProductionExceptionHandlerResponse response;
+ private InternalProcessorContext<Void, Void> expectedContext;
+ private String expectedProcessorNodeId;
+ private TaskId expectedTaskId;
+ private SerializationExceptionOrigin
expectedSerializationExceptionOrigin;
+
+ public ProductionExceptionHandlerMock(final
ProductionExceptionHandlerResponse response) {
+ this.response = response;
+ }
+
+ public ProductionExceptionHandlerMock(final
ProductionExceptionHandlerResponse response,
+ final
InternalProcessorContext<Void, Void> context,
+ final String processorNodeId,
+ final TaskId taskId) {
+ this(response);
+ this.expectedContext = context;
+ this.expectedProcessorNodeId = processorNodeId;
+ this.expectedTaskId = taskId;
+ }
+
+ public ProductionExceptionHandlerMock(final
ProductionExceptionHandlerResponse response,
+ final
InternalProcessorContext<Void, Void> context,
+ final String processorNodeId,
+ final TaskId taskId,
+ final
SerializationExceptionOrigin origin) {
+ this(response, context, processorNodeId, taskId);
+ this.expectedSerializationExceptionOrigin = origin;
+ }
+
+ @Override
+ public ProductionExceptionHandlerResponse handle(final
ErrorHandlerContext context,
+ final
ProducerRecord<byte[], byte[]> record,
+ final Exception
exception) {
+ assertInputs(context, exception);
+ return response;
+ }
+
+ @Override
+ public ProductionExceptionHandlerResponse
handleSerializationException(final ErrorHandlerContext context,
+
final ProducerRecord record,
+
final Exception exception,
+
final SerializationExceptionOrigin origin) {
+ assertInputs(context, exception);
+ assertEquals(expectedSerializationExceptionOrigin, origin);
+ return response;
+ }
+
+ @Override
+ public void configure(final Map<String, ?> configs) {
+ // do nothing
+ }
+
+ private void assertInputs(final ErrorHandlerContext context, final
Exception exception) {
+ assertEquals(expectedContext.recordContext().topic(),
context.topic());
+ assertEquals(expectedContext.recordContext().partition(),
context.partition());
+ assertEquals(expectedContext.recordContext().offset(),
context.offset());
+ assertEquals(expectedContext.recordContext().rawRecord().key(),
context.sourceRawKey());
+ assertEquals(expectedContext.recordContext().rawRecord().value(),
context.sourceRawValue());
Review Comment:
Done
--
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]