Search in sources :

Example 1 with AggProjectStarted

use of io.spine.test.aggregate.event.AggProjectStarted in project core-java by SpineEventEngine.

the class TestAggregate method handle.

@Assign
List<AggProjectStarted> handle(AggStartProject cmd, CommandContext ctx) {
    isStartProjectCommandHandled = true;
    final AggProjectStarted message = projectStarted(cmd.getProjectId());
    return newArrayList(message);
}
Also used : AggProjectStarted(io.spine.test.aggregate.event.AggProjectStarted) Assign(io.spine.server.command.Assign)

Example 2 with AggProjectStarted

use of io.spine.test.aggregate.event.AggProjectStarted 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);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) ProjectId(io.spine.test.aggregate.ProjectId) Event(io.spine.core.Event) PostponingEventDelivery(io.spine.server.aggregate.given.AggregateMessageDeliveryTestEnv.PostponingEventDelivery) AggProjectStarted(io.spine.test.aggregate.event.AggProjectStarted) Test(org.junit.Test)

Example 3 with AggProjectStarted

use of io.spine.test.aggregate.event.AggProjectStarted in project core-java by SpineEventEngine.

the class AggregateMessageDeliveryTestEnv method projectStarted.

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

Aggregations

AggProjectStarted (io.spine.test.aggregate.event.AggProjectStarted)3 Event (io.spine.core.Event)2 ProjectId (io.spine.test.aggregate.ProjectId)2 EventEnvelope (io.spine.core.EventEnvelope)1 PostponingEventDelivery (io.spine.server.aggregate.given.AggregateMessageDeliveryTestEnv.PostponingEventDelivery)1 Assign (io.spine.server.command.Assign)1 TestEventFactory (io.spine.server.command.TestEventFactory)1 Test (org.junit.Test)1