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);
}
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;
}
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;
}
Aggregations