use of io.eventuate.Int128 in project eventuate-local by eventuate-local.
the class AbstractTopicRelayTest method shouldCaptureAndPublishChange.
@Test
public void shouldCaptureAndPublishChange() throws ExecutionException, InterruptedException {
String aggregateType = "TestAggregate";
String eventType = "TestEvent";
List<EventTypeAndData> myEvents = Collections.singletonList(new EventTypeAndData(eventType, "{}", Optional.empty()));
long publishTime = System.currentTimeMillis();
EntityIdVersionAndEventIds ewidv = AsyncUtil.await(eventuateJdbcEventStore.save(aggregateType, myEvents, Optional.empty()));
Int128 expectedEventId = ewidv.getEntityVersion();
BlockingQueue<Int128> result = new LinkedBlockingDeque<>();
logger.debug("Looking for eventId {}", expectedEventId);
eventuateKafkaAggregateSubscriptions.subscribe("testSubscriber-" + getClass().getName(), Collections.singletonMap(aggregateType, Collections.singleton(eventType)), SubscriberOptions.DEFAULTS, se -> {
logger.debug("got se {}", se);
if (se.getId().equals(expectedEventId))
result.add(se.getId());
return CompletableFuture.completedFuture(null);
}).get();
Assert.assertNotNull("Failed to find eventId: " + expectedEventId, result.poll(30, TimeUnit.SECONDS));
Assert.assertNull(result.poll(30, TimeUnit.SECONDS));
long endTime = System.currentTimeMillis();
logger.debug("got the event I just published in msecs {}", endTime - publishTime);
// eventTableChangesToAggregateTopicRelay.stopCapturingChanges();
}
use of io.eventuate.Int128 in project eventuate-local by eventuate-local.
the class PrepareMigrationToNewCdcTest method shouldCaptureAndPublishChange.
@Test
public void shouldCaptureAndPublishChange() throws ExecutionException, InterruptedException {
String aggregateType = "TestAggregate_MIGRATION";
String eventType = "TestEvent_MIGRATION";
List<EventTypeAndData> myEvents = Collections.singletonList(new EventTypeAndData(eventType, "{}", Optional.empty()));
EntityIdVersionAndEventIds ewidv = AsyncUtil.await(eventuateJdbcEventStore.save(aggregateType, myEvents, Optional.empty()));
Int128 expectedEventId = ewidv.getEntityVersion();
BlockingQueue<Int128> result = new LinkedBlockingDeque<>();
eventuateKafkaAggregateSubscriptions.subscribe("testSubscriber", Collections.singletonMap(aggregateType, Collections.singleton(eventType)), SubscriberOptions.DEFAULTS, se -> {
logger.debug("got se {}", se);
if (se.getId().equals(expectedEventId))
result.add(se.getId());
return CompletableFuture.completedFuture(null);
}).get();
Assert.assertNotNull(result.poll(30, TimeUnit.SECONDS));
}
Aggregations