Search in sources :

Example 21 with EventEnvelope

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);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) StringValue(com.google.protobuf.StringValue) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 22 with EventEnvelope

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;
}
Also used : EventEnvelope(io.spine.core.EventEnvelope)

Example 23 with EventEnvelope

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);
    }
}
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)

Example 24 with EventEnvelope

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);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) TestEventFactory(io.spine.server.command.TestEventFactory) FloatValue(com.google.protobuf.FloatValue) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Aggregations

EventEnvelope (io.spine.core.EventEnvelope)24 Test (org.junit.Test)19 Event (io.spine.core.Event)9 StringValue (com.google.protobuf.StringValue)3 TestEventFactory (io.spine.server.command.TestEventFactory)3 GivenEvent (io.spine.server.event.given.EventBusTestEnv.GivenEvent)2 FailingSubscriber (io.spine.server.event.given.EventSubscriberTestEnv.FailingSubscriber)2 FloatValue (com.google.protobuf.FloatValue)1 Message (com.google.protobuf.Message)1 Command (io.spine.core.Command)1 EventClass (io.spine.core.EventClass)1 MessageEnvelope (io.spine.core.MessageEnvelope)1 GivenEvent (io.spine.core.given.GivenEvent)1 PostponingEventDelivery (io.spine.server.aggregate.given.AggregateMessageDeliveryTestEnv.PostponingEventDelivery)1 FailingAggregateRepository (io.spine.server.aggregate.given.AggregateRepositoryTestEnv.FailingAggregateRepository)1 EventCatcher (io.spine.server.event.given.CommandHandlerTestEnv.EventCatcher)1 GivenEvent (io.spine.server.event.given.EventEnricherTestEnv.GivenEvent)1 ExternalMessageClass (io.spine.server.integration.ExternalMessageClass)1 ExternalMessageDispatcher (io.spine.server.integration.ExternalMessageDispatcher)1 ExternalMessageEnvelope (io.spine.server.integration.ExternalMessageEnvelope)1