Search in sources :

Example 1 with SerializableConsumer

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));
}
Also used : SerializableConsumer(com.kloia.eventapis.kafka.SerializableConsumer) PublishedEvent(com.kloia.eventapis.common.PublishedEvent) EntityEvent(com.kloia.eventapis.cassandra.EntityEvent) Event(com.kloia.eventapis.pojos.Event) Test(org.junit.Test)

Example 2 with SerializableConsumer

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));
}
Also used : SerializableConsumer(com.kloia.eventapis.kafka.SerializableConsumer) PublishedEvent(com.kloia.eventapis.common.PublishedEvent) EntityEvent(com.kloia.eventapis.cassandra.EntityEvent) Event(com.kloia.eventapis.pojos.Event) Test(org.junit.Test)

Aggregations

EntityEvent (com.kloia.eventapis.cassandra.EntityEvent)2 PublishedEvent (com.kloia.eventapis.common.PublishedEvent)2 SerializableConsumer (com.kloia.eventapis.kafka.SerializableConsumer)2 Event (com.kloia.eventapis.pojos.Event)2 Test (org.junit.Test)2