use of com.kloia.eventapis.kafka.SerializableConsumer in project eventapis by kloiasoft.
the class CompositeRepositoryImplTest method shouldFailOperationWithFailEvent.
@Test
public void shouldFailOperationWithFailEvent() throws ConcurrentEventException, EventStoreException, JsonProcessingException {
when(eventRecorder.recordEntityEvent(eq(failEvent), anyLong(), previousEventKeyCaptor.capture(), concurrencyResolverFactoryCaptor.capture())).thenReturn(eventKey);
when(objectWriter.writeValueAsString(failEvent)).thenReturn(failEventJson);
compositeRepository.recordAndPublish(failEvent);
ArgumentCaptor<SerializableConsumer> serializableConsumerCaptor = ArgumentCaptor.forClass(SerializableConsumer.class);
verify(operationRepository).failOperation(eq("FailEvent"), serializableConsumerCaptor.capture());
Event event = new Event();
serializableConsumerCaptor.getValue().accept(event);
assertThat(event.getEventState(), equalTo(EventState.TXN_FAILED));
}
use of com.kloia.eventapis.kafka.SerializableConsumer in project eventapis by kloiasoft.
the class CompositeRepositoryImplTest method shouldSuccessOperationWithSuccessEvent.
@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));
}
Aggregations