Search in sources :

Example 1 with PrjProjectCreated

use of io.spine.test.projection.event.PrjProjectCreated 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)

Example 2 with PrjProjectCreated

use of io.spine.test.projection.event.PrjProjectCreated in project core-java by SpineEventEngine.

the class ProjectionEventDeliveryTestEnv method projectCreated.

public static Event projectCreated() {
    final ProjectId projectId = projectId();
    final TestEventFactory eventFactory = TestEventFactory.newInstance(pack(projectId), ProjectionEventDeliveryTestEnv.class);
    final PrjProjectCreated msg = PrjProjectCreated.newBuilder().setProjectId(projectId).build();
    final Event result = eventFactory.createEvent(msg);
    return result;
}
Also used : PrjProjectCreated(io.spine.test.projection.event.PrjProjectCreated) TestEventFactory(io.spine.server.command.TestEventFactory) ProjectId(io.spine.test.projection.ProjectId) Event(io.spine.core.Event)

Example 3 with PrjProjectCreated

use of io.spine.test.projection.event.PrjProjectCreated in project core-java by SpineEventEngine.

the class Given method validEvent.

static Event validEvent() {
    final Command cmd = validCommand();
    final PrjProjectCreated eventMessage = PrjProjectCreated.newBuilder().setProjectId(ProjectId.newBuilder().setId("12345AD0")).build();
    final StringValue producerId = toMessage(Given.class.getSimpleName());
    final EventFactory eventFactory = EventFactory.on(CommandEnvelope.of(cmd), Identifier.pack(producerId));
    final Event event = eventFactory.createEvent(eventMessage, Tests.<Version>nullRef());
    final Event result = event.toBuilder().setContext(event.getContext().toBuilder().setEnrichment(Enrichment.newBuilder().setDoNotEnrich(true)).build()).build();
    return result;
}
Also used : PrjProjectCreated(io.spine.test.projection.event.PrjProjectCreated) Command(io.spine.core.Command) EventFactory(io.spine.server.event.EventFactory) Event(io.spine.core.Event) StringValue(com.google.protobuf.StringValue)

Aggregations

Event (io.spine.core.Event)3 PrjProjectCreated (io.spine.test.projection.event.PrjProjectCreated)3 ProjectId (io.spine.test.projection.ProjectId)2 StringValue (com.google.protobuf.StringValue)1 Command (io.spine.core.Command)1 EventEnvelope (io.spine.core.EventEnvelope)1 TestEventFactory (io.spine.server.command.TestEventFactory)1 EventFactory (io.spine.server.event.EventFactory)1 PostponingEventDelivery (io.spine.server.projection.given.ProjectionEventDeliveryTestEnv.PostponingEventDelivery)1 Test (org.junit.Test)1