Search in sources :

Example 1 with Int128

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();
}
Also used : EntityIdVersionAndEventIds(io.eventuate.javaclient.commonimpl.EntityIdVersionAndEventIds) AggregateCrud(io.eventuate.javaclient.commonimpl.AggregateCrud) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) BlockingQueue(java.util.concurrent.BlockingQueue) CompletableFuture(java.util.concurrent.CompletableFuture) Int128(io.eventuate.Int128) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) Optional(java.util.Optional) EventTypeAndData(io.eventuate.javaclient.commonimpl.EventTypeAndData) SubscriberOptions(io.eventuate.SubscriberOptions) EntityIdVersionAndEventIds(io.eventuate.javaclient.commonimpl.EntityIdVersionAndEventIds) org.junit(org.junit) EventuateKafkaAggregateSubscriptions(io.eventuate.local.java.jdbckafkastore.EventuateKafkaAggregateSubscriptions) Collections(java.util.Collections) AsyncUtil(io.eventuate.testutil.AsyncUtil) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) EventTypeAndData(io.eventuate.javaclient.commonimpl.EventTypeAndData) Int128(io.eventuate.Int128)

Example 2 with Int128

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));
}
Also used : EntityIdVersionAndEventIds(io.eventuate.javaclient.commonimpl.EntityIdVersionAndEventIds) DirtiesContext(org.springframework.test.annotation.DirtiesContext) AggregateCrud(io.eventuate.javaclient.commonimpl.AggregateCrud) Logger(org.slf4j.Logger) EnableAutoConfiguration(org.springframework.boot.autoconfigure.EnableAutoConfiguration) java.util.concurrent(java.util.concurrent) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Import(org.springframework.context.annotation.Import) Test(org.junit.Test) Int128(io.eventuate.Int128) List(java.util.List) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) EventuateLocalConfiguration(io.eventuate.local.java.jdbckafkastore.EventuateLocalConfiguration) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Optional(java.util.Optional) EventTypeAndData(io.eventuate.javaclient.commonimpl.EventTypeAndData) SubscriberOptions(io.eventuate.SubscriberOptions) EntityIdVersionAndEventIds(io.eventuate.javaclient.commonimpl.EntityIdVersionAndEventIds) EventuateKafkaAggregateSubscriptions(io.eventuate.local.java.jdbckafkastore.EventuateKafkaAggregateSubscriptions) Assert(org.junit.Assert) Collections(java.util.Collections) AsyncUtil(io.eventuate.testutil.AsyncUtil) EventTypeAndData(io.eventuate.javaclient.commonimpl.EventTypeAndData) Int128(io.eventuate.Int128) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Int128 (io.eventuate.Int128)2 SubscriberOptions (io.eventuate.SubscriberOptions)2 AggregateCrud (io.eventuate.javaclient.commonimpl.AggregateCrud)2 EntityIdVersionAndEventIds (io.eventuate.javaclient.commonimpl.EntityIdVersionAndEventIds)2 EventTypeAndData (io.eventuate.javaclient.commonimpl.EventTypeAndData)2 EventuateKafkaAggregateSubscriptions (io.eventuate.local.java.jdbckafkastore.EventuateKafkaAggregateSubscriptions)2 AsyncUtil (io.eventuate.testutil.AsyncUtil)2 Collections (java.util.Collections)2 List (java.util.List)2 Optional (java.util.Optional)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 EventuateLocalConfiguration (io.eventuate.local.java.jdbckafkastore.EventuateLocalConfiguration)1 java.util.concurrent (java.util.concurrent)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)1 TimeUnit (java.util.concurrent.TimeUnit)1