Search in sources :

Example 1 with ProjectCreated

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

the class ProjectionRepositoryShould method checkDoesNotDispatchEventWith.

private void checkDoesNotDispatchEventWith(Status status) {
    repository().setStatus(status);
    final ProjectCreated eventMsg = projectCreated();
    final Event event = createEvent(PRODUCER_ID, eventMsg);
    repository().dispatch(event);
    assertFalse(TestProjection.processed(eventMsg));
}
Also used : Event(io.spine.base.Event) ProjectCreated(io.spine.test.projection.event.ProjectCreated)

Example 2 with ProjectCreated

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

the class ProjectionRepositoryShould method use_id_set_function.

@Test
public void use_id_set_function() {
    final IdSetEventFunction<ProjectId, ProjectCreated> delegateFn = new IdSetEventFunction<ProjectId, ProjectCreated>() {

        @Override
        public Set<ProjectId> apply(ProjectCreated message, EventContext context) {
            return newHashSet();
        }
    };
    final IdSetEventFunction<ProjectId, ProjectCreated> idSetFunction = spy(delegateFn);
    repository().addIdSetFunction(ProjectCreated.class, idSetFunction);
    final Event event = createEvent(PRODUCER_ID, projectCreated());
    repository().dispatch(event);
    final ProjectCreated expectedEventMessage = Events.getMessage(event);
    final EventContext context = event.getContext();
    verify(idSetFunction).apply(eq(expectedEventMessage), eq(context));
}
Also used : EventContext(io.spine.base.EventContext) ProjectId(io.spine.test.projection.ProjectId) Event(io.spine.base.Event) IdSetEventFunction(io.spine.server.entity.idfunc.IdSetEventFunction) ProjectCreated(io.spine.test.projection.event.ProjectCreated) Test(org.junit.Test)

Example 3 with ProjectCreated

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

the class ProjectionRepositoryShould method ensureCatchesUpFromEventStorage.

private void ensureCatchesUpFromEventStorage(ProjectionRepository<ProjectId, TestProjection, Project> repo) {
    final EventStore eventStore = boundedContext.getEventBus().getEventStore();
    final TestEventFactory eventFactory = newEventFactory(PRODUCER_ID);
    // Put events into the EventStore.
    final ProjectCreated projectCreated = ProjectCreated.newBuilder().setProjectId(ID).build();
    final Event projectCreatedEvent = eventFactory.createEvent(projectCreated);
    appendEvent(eventStore, projectCreatedEvent);
    final TaskAdded taskAdded = TaskAdded.newBuilder().setProjectId(ID).build();
    final Event taskAddedEvent = eventFactory.createEvent(taskAdded);
    appendEvent(eventStore, taskAddedEvent);
    final ProjectStarted projectStarted = ProjectStarted.newBuilder().setProjectId(ID).build();
    final Event projectStartedEvent = eventFactory.createEvent(projectStarted);
    appendEvent(eventStore, projectStartedEvent);
    repo.catchUp();
    assertTrue(TestProjection.processed(projectCreated));
    assertTrue(TestProjection.processed(taskAdded));
    assertTrue(TestProjection.processed(projectStarted));
}
Also used : EventStore(io.spine.server.event.EventStore) TestEventFactory(io.spine.test.TestEventFactory) ProjectStarted(io.spine.test.projection.event.ProjectStarted) TaskAdded(io.spine.test.projection.event.TaskAdded) Event(io.spine.base.Event) ProjectCreated(io.spine.test.projection.event.ProjectCreated)

Aggregations

Event (io.spine.base.Event)3 ProjectCreated (io.spine.test.projection.event.ProjectCreated)3 EventContext (io.spine.base.EventContext)1 IdSetEventFunction (io.spine.server.entity.idfunc.IdSetEventFunction)1 EventStore (io.spine.server.event.EventStore)1 TestEventFactory (io.spine.test.TestEventFactory)1 ProjectId (io.spine.test.projection.ProjectId)1 ProjectStarted (io.spine.test.projection.event.ProjectStarted)1 TaskAdded (io.spine.test.projection.event.TaskAdded)1 Test (org.junit.Test)1