use of com.kloia.eventapis.cassandra.EntityEvent in project eventapis by kloiasoft.
the class CompositeRepositoryImplTest method shouldRecordAndPublishWithPublishedEvent.
@Test
public void shouldRecordAndPublishWithPublishedEvent() throws ConcurrentEventException, EventStoreException, JsonProcessingException {
mockCommon(intermediateEvent);
EventKey actual = compositeRepository.recordAndPublish(intermediateEvent);
assertCommon(intermediateEvent);
assertThat(actual, equalTo(eventKey));
assertThat(previousEventKeyCaptor.getValue(), equalTo(Optional.empty()));
assertThat(concurrencyResolverFactoryCaptor.getValue().apply(new EntityEvent()).getClass(), equalTo(DefaultConcurrencyResolver.class));
}
use of com.kloia.eventapis.cassandra.EntityEvent in project eventapis by kloiasoft.
the class CompositeRepositoryImplTest method shouldRecordAndPublishWithPreviousEventAndPublishedEvent.
@Test
public void shouldRecordAndPublishWithPreviousEventAndPublishedEvent() throws JsonProcessingException, EventStoreException, ConcurrentEventException {
mockCommon(intermediateEvent);
Entity previousEntity = mock(Entity.class);
EventKey previousEntityEventKey = new EventKey();
when(previousEntity.getEventKey()).thenReturn(previousEntityEventKey);
EventKey actual = compositeRepository.recordAndPublish(previousEntity, intermediateEvent);
assertCommon(intermediateEvent);
assertThat(actual, equalTo(eventKey));
assertThat(previousEventKeyCaptor.getValue().isPresent(), equalTo(true));
assertThat(previousEventKeyCaptor.getValue().get(), equalTo(previousEntityEventKey));
assertThat(concurrencyResolverFactoryCaptor.getValue().apply(new EntityEvent()).getClass(), equalTo(DefaultConcurrencyResolver.class));
}
use of com.kloia.eventapis.cassandra.EntityEvent in project eventapis by kloiasoft.
the class CompositeRepositoryImplTest method shouldRecordAndPublishWithPreviousEventKeyAndPublishedEvent.
@Test
public void shouldRecordAndPublishWithPreviousEventKeyAndPublishedEvent() throws JsonProcessingException, EventStoreException, ConcurrentEventException {
mockCommon(intermediateEvent);
EventKey previousEntityEventKey = new EventKey();
EventKey actual = compositeRepository.recordAndPublish(previousEntityEventKey, intermediateEvent);
assertCommon(intermediateEvent);
assertThat(actual, equalTo(eventKey));
assertThat(previousEventKeyCaptor.getValue().isPresent(), equalTo(true));
assertThat(previousEventKeyCaptor.getValue().get(), equalTo(previousEntityEventKey));
assertThat(concurrencyResolverFactoryCaptor.getValue().apply(new EntityEvent()).getClass(), equalTo(DefaultConcurrencyResolver.class));
}
use of com.kloia.eventapis.cassandra.EntityEvent in project eventapis by kloiasoft.
the class CompositeRepositoryImplTest method shouldRecordAndPublishWithPreviousEventKeyAndPublishedEventAndConcurrencyResolverFactory.
@Test
public void shouldRecordAndPublishWithPreviousEventKeyAndPublishedEventAndConcurrencyResolverFactory() throws JsonProcessingException, EventStoreException, ConcurrentEventException {
mockCommon(intermediateEvent);
EventKey previousEntityEventKey = new EventKey();
ConcurrencyResolver concurrencyResolver = mock(ConcurrencyResolver.class);
Function<EntityEvent, ConcurrencyResolver<ConcurrentEventException>> factory = entityEvent -> concurrencyResolver;
EventKey actual = compositeRepository.recordAndPublish(previousEntityEventKey, intermediateEvent, factory);
assertCommon(intermediateEvent);
assertThat(actual, equalTo(eventKey));
assertThat(previousEventKeyCaptor.getValue().isPresent(), equalTo(true));
assertThat(previousEventKeyCaptor.getValue().get(), equalTo(previousEntityEventKey));
assertThat(concurrencyResolverFactoryCaptor.getValue(), equalTo(factory));
}
use of com.kloia.eventapis.cassandra.EntityEvent in project eventapis by kloiasoft.
the class CompositeRepositoryImplTest method shouldRecordAndPublishWithPreviousEventAndPublishedEventAndConcurrencyResolverFactory.
@Test
public void shouldRecordAndPublishWithPreviousEventAndPublishedEventAndConcurrencyResolverFactory() throws JsonProcessingException, EventStoreException, ConcurrentEventException {
mockCommon(intermediateEvent);
Entity previousEntity = mock(Entity.class);
EventKey previousEntityEventKey = new EventKey();
when(previousEntity.getEventKey()).thenReturn(previousEntityEventKey);
ConcurrencyResolver concurrencyResolver = mock(ConcurrencyResolver.class);
Function<EntityEvent, ConcurrencyResolver<ConcurrentEventException>> factory = entityEvent -> concurrencyResolver;
EventKey actual = compositeRepository.recordAndPublish(previousEntity, intermediateEvent, factory);
assertCommon(intermediateEvent);
assertThat(actual, equalTo(eventKey));
assertThat(previousEventKeyCaptor.getValue().isPresent(), equalTo(true));
assertThat(previousEventKeyCaptor.getValue().get(), equalTo(previousEntityEventKey));
assertThat(concurrencyResolverFactoryCaptor.getValue(), equalTo(factory));
}
Aggregations