use of org.apache.kafka.streams.processor.MockProcessorContext in project apache-kafka-on-k8s by banzaicloud.
the class MockProcessorContextTest method shouldCaptureOutputRecordsUsingTo.
@Test
public void shouldCaptureOutputRecordsUsingTo() {
final AbstractProcessor<String, Long> processor = new AbstractProcessor<String, Long>() {
@Override
public void process(final String key, final Long value) {
context().forward(key + value, key.length() + value, To.all());
}
};
final MockProcessorContext context = new MockProcessorContext();
processor.init(context);
processor.process("foo", 5L);
processor.process("barbaz", 50L);
final Iterator<CapturedForward> forwarded = context.forwarded().iterator();
assertEquals(new KeyValue<>("foo5", 8L), forwarded.next().keyValue());
assertEquals(new KeyValue<>("barbaz50", 56L), forwarded.next().keyValue());
assertFalse(forwarded.hasNext());
context.resetForwards();
assertEquals(0, context.forwarded().size());
}
Aggregations