@Test public void shouldSuccessOperationWithSuccessEvent() throws ConcurrentEventException, EventStoreException, JsonProcessingException { when(eventRecorder.recordEntityEvent(eq(successEvent), anyLong(), previousEventKeyCaptor.capture(), concurrencyResolverFactoryCaptor.capture())).thenReturn(eventKey); when(objectWriter.writeValueAsString(successEvent)).thenReturn(successEventJson); compositeRepository.recordAndPublish(successEvent); ArgumentCaptor<SerializableConsumer> serializableConsumerCaptor = ArgumentCaptor.forClass(SerializableConsumer.class); verify(operationRepository).successOperation(eq("SuccessEvent"), serializableConsumerCaptor.capture()); Event event = new Event(); serializableConsumerCaptor.getValue().accept(event); assertThat(event.getEventState(), equalTo(EventState.TXN_SUCCEEDED)); }
@Override public <P extends PublishedEvent> EventKey recordAndPublish(P publishedEvent) throws EventStoreException, ConcurrentEventException { return recordAndPublishInternal(publishedEvent, Optional.empty(), entityEvent -> new DefaultConcurrencyResolver()); }
CompositeRepositoryImpl implements EventRepository { @Override public <P extends PublishedEvent> EventKey recordAndPublish(P publishedEvent) throws EventStoreException, ConcurrentEventException { return recordAndPublishInternal(publishedEvent, Optional.empty(), entityEvent -> new DefaultConcurrencyResolver()); } }
CompositeRepositoryImpl implements EventRepository { @Override public <P extends PublishedEvent> EventKey recordAndPublish(P publishedEvent) throws EventStoreException, ConcurrentEventException { return recordAndPublishInternal(publishedEvent, Optional.empty(), entityEvent -> new DefaultConcurrencyResolver()); } CompositeRepositoryImpl(EventRecorder eventRecorder, ObjectMapper objectMapper,
                                   IOperationRepository operationRepository); }
CompositeRepositoryImpl implements EventRepository { @Override public <P extends PublishedEvent> EventKey recordAndPublish(P publishedEvent) throws EventStoreException, ConcurrentEventException { return recordAndPublishInternal(publishedEvent, Optional.empty(), entityEvent -> new DefaultConcurrencyResolver()); } CompositeRepositoryImpl(EventRecorder eventRecorder, ObjectMapper objectMapper,
                                   IOperationRepository operationRepository); @Override List<EntityEvent> markFail(String opId); @Override EventKey recordAndPublish(P publishedEvent); @Override EventKey recordAndPublish(Entity previousEntity, P publishedEvent); @Override EventKey recordAndPublish(EventKey previousEventKey, P publishedEvent); @Override EventKey recordAndPublish(
            Entity previousEntity, P publishedEvent, Function<EntityEvent, ConcurrencyResolver<T>> concurrencyResolverFactory
    ); @Override EventKey recordAndPublish(
            EventKey eventKey, P publishedEvent, Function<EntityEvent, ConcurrencyResolver<T>> concurrencyResolverFactory
    ); @Override EventKey recordAndPublish(
            Entity entity, P publishedEvent, Supplier<ConcurrentEventResolver<P, T>> concurrencyResolverFactory
    ); @Override EventKey recordAndPublish(
            EventKey previousEventKey, P publishedEvent, Supplier<ConcurrentEventResolver<P, T>> concurrencyResolverFactory
    ); @Override EventRecorder getEventRecorder(); }
CompositeRepositoryImpl implements EventRepository { @Override public <P extends PublishedEvent> EventKey recordAndPublish(P publishedEvent) throws EventStoreException, ConcurrentEventException { return recordAndPublishInternal(publishedEvent, Optional.empty(), entityEvent -> new DefaultConcurrencyResolver()); } CompositeRepositoryImpl(EventRecorder eventRecorder, ObjectMapper objectMapper,
                                   IOperationRepository operationRepository); @Override List<EntityEvent> markFail(String opId); @Override EventKey recordAndPublish(P publishedEvent); @Override EventKey recordAndPublish(Entity previousEntity, P publishedEvent); @Override EventKey recordAndPublish(EventKey previousEventKey, P publishedEvent); @Override EventKey recordAndPublish(
            Entity previousEntity, P publishedEvent, Function<EntityEvent, ConcurrencyResolver<T>> concurrencyResolverFactory
    ); @Override EventKey recordAndPublish(
            EventKey eventKey, P publishedEvent, Function<EntityEvent, ConcurrencyResolver<T>> concurrencyResolverFactory
    ); @Override EventKey recordAndPublish(
            Entity entity, P publishedEvent, Supplier<ConcurrentEventResolver<P, T>> concurrencyResolverFactory
    ); @Override EventKey recordAndPublish(
            EventKey previousEventKey, P publishedEvent, Supplier<ConcurrentEventResolver<P, T>> concurrencyResolverFactory
    ); @Override EventRecorder getEventRecorder();  }