use of io.spine.core.EventEnvelope in project core-java by SpineEventEngine.
the class EventRoutingShould method apply_custom_route.
@Test
public void apply_custom_route() {
eventRouting.route(StringValue.class, customRoute);
// An event which has `StringValue` as its message, which should go the custom route.
final EventEnvelope event = EventEnvelope.of(eventFactory.createEvent(TestValues.newUuidValue()));
final Set<Long> ids = eventRouting.apply(event.getMessage(), event.getEventContext());
assertEquals(CUSTOM_ROUTE, ids);
}
use of io.spine.core.EventEnvelope in project core-java by SpineEventEngine.
the class AggregateMessageDeliveryShould method postpone_events_dispatched_to_reactor_method.
@Test
public void postpone_events_dispatched_to_reactor_method() {
assertNull(ReactingProject.getEventReceived());
final Event event = projectStarted();
boundedContext.getEventBus().post(event);
assertNull(ReactingProject.getEventReceived());
final EventEnvelope expectedEnvelope = EventEnvelope.of(event);
final PostponingEventDelivery delivery = repository.getEventEndpointDelivery();
final Map<ProjectId, EventEnvelope> postponedEvents = delivery.getPostponedEvents();
assertTrue(postponedEvents.size() == 1 && postponedEvents.containsValue(expectedEnvelope));
final ProjectId projectId = postponedEvents.keySet().iterator().next();
delivery.deliverNow(projectId, postponedEvents.get(projectId));
final AggProjectStarted deliveredEventMsg = ReactingProject.getEventReceived();
assertNotNull(deliveredEventMsg);
assertEquals(Events.getMessage(event), deliveredEventMsg);
}
use of io.spine.core.EventEnvelope in project core-java by SpineEventEngine.
the class EventEnricherShould method confirm_that_event_can_not_be_enriched_if_no_such_enrichment_registered.
@Test
public void confirm_that_event_can_not_be_enriched_if_no_such_enrichment_registered() {
final EventEnvelope dummyEvent = EventEnvelope.of(createEvent(toMessage(newUuid())));
assertFalse(enricher.canBeEnriched(dummyEvent));
}
use of io.spine.core.EventEnvelope in project core-java by SpineEventEngine.
the class EventSubscriberShould method catch_exceptions_caused_by_methods.
@Test
public void catch_exceptions_caused_by_methods() {
// Create event which should fail.
final EventEnvelope eventEnvelope = createEvent(false);
final Set<String> dispatchingResult = subscriber.dispatch(eventEnvelope);
final FailingSubscriber sub = (FailingSubscriber) this.subscriber;
assertTrue(sub.isMethodCalled());
assertEquals(0, dispatchingResult.size());
assertEquals(eventEnvelope, sub.getLastErrorEnvelope());
assertNotNull(sub.getLastException());
}
use of io.spine.core.EventEnvelope in project core-java by SpineEventEngine.
the class PmMessageDeliveryShould method postpone_events_dispatched_to_reactor_method.
@Test
public void postpone_events_dispatched_to_reactor_method() {
assertNull(ReactingProjectWizard.getEventReceived());
final Event event = projectStarted();
boundedContext.getEventBus().post(event);
assertNull(ReactingProjectWizard.getEventReceived());
final EventEnvelope expectedEnvelope = EventEnvelope.of(event);
final PostponingEventDelivery delivery = repository.getEventEndpointDelivery();
final Map<ProjectId, EventEnvelope> postponedEvents = delivery.getPostponedEvents();
assertTrue(postponedEvents.size() == 1 && postponedEvents.containsValue(expectedEnvelope));
final ProjectId projectId = postponedEvents.keySet().iterator().next();
delivery.deliverNow(projectId, postponedEvents.get(projectId));
final PmProjectStarted deliveredEventMsg = ReactingProjectWizard.getEventReceived();
assertNotNull(deliveredEventMsg);
assertEquals(Events.getMessage(event), deliveredEventMsg);
}
Aggregations