Search in sources :

Example 1 with EventEnvelope

use of io.spine.envelope.EventEnvelope in project core-java by SpineEventEngine.

the class EventBusShould method deliver_postponed_event_to_dispatcher_using_configured_executor.

@Test
public void deliver_postponed_event_to_dispatcher_using_configured_executor() {
    final BareDispatcher dispatcher = new BareDispatcher();
    eventBusWithPosponedExecution.register(dispatcher);
    final Event event = Given.AnEvent.projectCreated();
    eventBusWithPosponedExecution.post(event);
    final Set<EventEnvelope> postponedEvents = postponedDispatcherDelivery.getPostponedEvents();
    final EventEnvelope postponedEvent = postponedEvents.iterator().next();
    verify(delegateDispatcherExecutor, never()).execute(any(Runnable.class));
    postponedDispatcherDelivery.deliverNow(postponedEvent, dispatcher.getClass());
    assertTrue(dispatcher.isDispatchCalled());
    verify(delegateDispatcherExecutor).execute(any(Runnable.class));
}
Also used : EventEnvelope(io.spine.envelope.EventEnvelope) Event(io.spine.base.Event) Test(org.junit.Test)

Example 2 with EventEnvelope

use of io.spine.envelope.EventEnvelope in project core-java by SpineEventEngine.

the class EventEnricher method enrich.

/**
     * Enriches the passed event.
     *
     * @throws IllegalArgumentException if the passed event cannot be enriched
     * @see #canBeEnriched(Event)
     */
public Event enrich(Event event) {
    checkTypeRegistered(event);
    checkEnabled(event);
    final EventEnvelope envelope = EventEnvelope.of(event);
    final Action action = new Action(this, envelope);
    final Event result = action.perform();
    return result;
}
Also used : EventEnvelope(io.spine.envelope.EventEnvelope) Event(io.spine.base.Event)

Aggregations

Event (io.spine.base.Event)2 EventEnvelope (io.spine.envelope.EventEnvelope)2 Test (org.junit.Test)1