use of io.zeebe.broker.topic.Events in project zeebe by zeebe-io.
the class TypedStreamProcessorTest method shouldWriteSourceEventAndProducerOnBatch.
@Test
public void shouldWriteSourceEventAndProducerOnBatch() {
// given
final TypedStreamEnvironment env = new TypedStreamEnvironment(streams.getLogStream(STREAM_NAME), output);
final TypedStreamProcessor streamProcessor = env.newStreamProcessor().onEvent(EventType.TOPIC_EVENT, TopicState.CREATE, new BatchProcessor()).build();
final StreamProcessorControl streamProcessorControl = streams.initStreamProcessor(STREAM_NAME, STREAM_PROCESSOR_ID, () -> streamProcessor);
streamProcessorControl.start();
final long firstEventPosition = streams.newEvent(STREAM_NAME).event(createTopic("foo", 1)).write();
// when
streamProcessorControl.unblock();
final LoggedEvent writtenEvent = doRepeatedly(() -> streams.events(STREAM_NAME).filter(Events::isTopicEvent).filter(e -> Events.asTopicEvent(e).getState() == TopicState.CREATE_REJECTED).findFirst()).until(o -> o.isPresent()).get();
// then
assertThat(writtenEvent.getProducerId()).isEqualTo(STREAM_PROCESSOR_ID);
assertThat(writtenEvent.getSourceEventLogStreamPartitionId()).isEqualTo(stream.getPartitionId());
assertThat(writtenEvent.getSourceEventPosition()).isEqualTo(firstEventPosition);
}
Aggregations