use of io.spine.core.EventEnvelope in project core-java by SpineEventEngine.
the class ProcessManagerShould method throw_exception_if_dispatch_unknown_event.
@Test(expected = IllegalStateException.class)
public void throw_exception_if_dispatch_unknown_event() {
final StringValue unknownEvent = StringValue.getDefaultInstance();
final EventEnvelope envelope = EventEnvelope.of(eventFactory.createEvent(unknownEvent));
dispatch(processManager, envelope);
}
use of io.spine.core.EventEnvelope in project core-java by SpineEventEngine.
the class PmEventEndpoint method getTargets.
@Override
protected Set<I> getTargets() {
final EventEnvelope event = envelope();
final Set<I> ids = repository().eventRouting().apply(event.getMessage(), event.getEventContext());
return ids;
}
use of io.spine.core.EventEnvelope 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);
}
}
use of io.spine.core.EventEnvelope in project core-java by SpineEventEngine.
the class AggregateMessageDispatcherShould method dispatch_event.
@Test
public void dispatch_event() {
final TestEventFactory factory = TestEventFactory.newInstance(getClass());
final float messageValue = 2017.0729f;
final FloatValue message = FloatValue.newBuilder().setValue(messageValue).build();
final EventEnvelope eventEnvelope = EventEnvelope.of(factory.createEvent(message));
final List<? extends Message> eventMessages = dispatchEvent(aggregate, eventEnvelope);
assertTrue(aggregate.getState().getValue().contains(String.valueOf(messageValue)));
assertEquals(1, eventMessages.size());
assertTrue(eventMessages.get(0) instanceof StringValue);
}
Aggregations