use of io.eventuate.local.common.PublishedEvent in project eventuate-local by eventuate-local.
the class CdcProcessorTest method shouldReadNewEventsOnly.
@Test
public void shouldReadNewEventsOnly() throws InterruptedException {
BlockingQueue<PublishedEvent> publishedEvents = new LinkedBlockingDeque<>();
CdcProcessor<PublishedEvent> cdcProcessor = createCdcProcessor();
cdcProcessor.start(publishedEvent -> {
publishedEvents.add(publishedEvent);
onEventSent(publishedEvent);
});
String accountCreatedEventData = generateAccountCreatedEvent();
EntityIdVersionAndEventIds entityIdVersionAndEventIds = saveEvent(localAggregateCrud, accountCreatedEventData);
waitForEvent(publishedEvents, entityIdVersionAndEventIds.getEntityVersion(), LocalDateTime.now().plusSeconds(10), accountCreatedEventData);
cdcProcessor.stop();
Thread.sleep(10000);
publishedEvents.clear();
cdcProcessor.start(publishedEvent -> {
publishedEvents.add(publishedEvent);
onEventSent(publishedEvent);
});
List<String> excludedIds = entityIdVersionAndEventIds.getEventIds().stream().map(Int128::asString).collect(Collectors.toList());
accountCreatedEventData = generateAccountCreatedEvent();
entityIdVersionAndEventIds = saveEvent(localAggregateCrud, accountCreatedEventData);
waitForEventExcluding(publishedEvents, entityIdVersionAndEventIds.getEntityVersion(), LocalDateTime.now().plusSeconds(10), accountCreatedEventData, excludedIds);
cdcProcessor.stop();
}
Aggregations