use of org.apache.kafka.streams.processor.api.ProcessorContext in project kafka by apache.
the class MockProcessorContextAPITest method shouldCapturePunctuator.
@Test
public void shouldCapturePunctuator() {
final Processor<String, Long, Void, Void> processor = new Processor<String, Long, Void, Void>() {
@Override
public void init(final ProcessorContext<Void, Void> context) {
context.schedule(Duration.ofSeconds(1L), PunctuationType.WALL_CLOCK_TIME, timestamp -> context.commit());
}
@Override
public void process(final Record<String, Long> record) {
}
};
final MockProcessorContext<Void, Void> context = new MockProcessorContext<>();
processor.init(context);
final MockProcessorContext.CapturedPunctuator capturedPunctuator = context.scheduledPunctuators().get(0);
assertThat(capturedPunctuator.getInterval(), is(Duration.ofMillis(1000L)));
assertThat(capturedPunctuator.getType(), is(PunctuationType.WALL_CLOCK_TIME));
assertThat(capturedPunctuator.cancelled(), is(false));
final Punctuator punctuator = capturedPunctuator.getPunctuator();
assertThat(context.committed(), is(false));
punctuator.punctuate(1234L);
assertThat(context.committed(), is(true));
}
Aggregations