Search in sources :

Example 1 with TestProjectionRepository

use of io.spine.server.projection.given.ProjectionRepositoryTestEnv.TestProjectionRepository in project core-java by SpineEventEngine.

the class ProjectionRepositoryShould method log_error_if_dispatch_unknown_event.

@Test
public void log_error_if_dispatch_unknown_event() {
    final StringValue unknownEventMessage = StringValue.getDefaultInstance();
    final Event event = GivenEvent.withMessage(unknownEventMessage);
    repository().dispatch(EventEnvelope.of(event));
    TestProjectionRepository testRepo = (TestProjectionRepository) repository();
    assertTrue(testRepo.getLastErrorEnvelope() instanceof EventEnvelope);
    assertEquals(Events.getMessage(event), testRepo.getLastErrorEnvelope().getMessage());
    assertEquals(event, testRepo.getLastErrorEnvelope().getOuterObject());
    // It must be "illegal argument type" since projections of this repository
    // do not handle such events.
    assertTrue(testRepo.getLastException() instanceof IllegalArgumentException);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) GivenEvent(io.spine.core.given.GivenEvent) Event(io.spine.core.Event) StringValue(com.google.protobuf.StringValue) TestProjectionRepository(io.spine.server.projection.given.ProjectionRepositoryTestEnv.TestProjectionRepository) Test(org.junit.Test)

Aggregations

StringValue (com.google.protobuf.StringValue)1 Event (io.spine.core.Event)1 EventEnvelope (io.spine.core.EventEnvelope)1 GivenEvent (io.spine.core.given.GivenEvent)1 TestProjectionRepository (io.spine.server.projection.given.ProjectionRepositoryTestEnv.TestProjectionRepository)1 Test (org.junit.Test)1