Search in sources :

Example 1 with PostponingEventDelivery

use of io.spine.server.projection.given.ProjectionEventDeliveryTestEnv.PostponingEventDelivery in project core-java by SpineEventEngine.

the class ProjectionEventDeliveryShould method postpone_events_dispatched_to_subscriber_method.

@Test
public void postpone_events_dispatched_to_subscriber_method() {
    assertNull(ProjectDetails.getEventReceived());
    final Event event = projectCreated();
    boundedContext.getEventBus().post(event);
    assertNull(ProjectDetails.getEventReceived());
    final EventEnvelope expectedEnvelope = EventEnvelope.of(event);
    final PostponingEventDelivery delivery = repository.getEndpointDelivery();
    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 PrjProjectCreated deliveredEventMsg = ProjectDetails.getEventReceived();
    assertNotNull(deliveredEventMsg);
    assertEquals(Events.getMessage(event), deliveredEventMsg);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) PrjProjectCreated(io.spine.test.projection.event.PrjProjectCreated) ProjectId(io.spine.test.projection.ProjectId) Event(io.spine.core.Event) PostponingEventDelivery(io.spine.server.projection.given.ProjectionEventDeliveryTestEnv.PostponingEventDelivery) Test(org.junit.Test)

Aggregations

Event (io.spine.core.Event)1 EventEnvelope (io.spine.core.EventEnvelope)1 PostponingEventDelivery (io.spine.server.projection.given.ProjectionEventDeliveryTestEnv.PostponingEventDelivery)1 ProjectId (io.spine.test.projection.ProjectId)1 PrjProjectCreated (io.spine.test.projection.event.PrjProjectCreated)1 Test (org.junit.Test)1