Search in sources :

Example 1 with EventCatcher

use of io.spine.server.event.given.CommandHandlerTestEnv.EventCatcher in project core-java by SpineEventEngine.

the class CommandHandlerShould method post_generated_events_to_event_bus.

@Test
public void post_generated_events_to_event_bus() {
    final Command cmd = Given.ACommand.startProject();
    final EventCatcher eventCatcher = new EventCatcher();
    eventBus.register(eventCatcher);
    handler.handle(cmd);
    final ImmutableList<Message> expectedMessages = handler.getEventsOnStartProjectCmd();
    final List<EventEnvelope> actualEvents = eventCatcher.getDispatched();
    for (int i = 0; i < expectedMessages.size(); i++) {
        final Message expected = expectedMessages.get(i);
        final Message actual = Events.getMessage(actualEvents.get(i).getOuterObject());
        assertEquals(expected, actual);
    }
}
Also used : EventCatcher(io.spine.server.event.given.CommandHandlerTestEnv.EventCatcher) EventEnvelope(io.spine.core.EventEnvelope) Message(com.google.protobuf.Message) Command(io.spine.core.Command) Test(org.junit.Test)

Aggregations

Message (com.google.protobuf.Message)1 Command (io.spine.core.Command)1 EventEnvelope (io.spine.core.EventEnvelope)1 EventCatcher (io.spine.server.event.given.CommandHandlerTestEnv.EventCatcher)1 Test (org.junit.Test)1