Search in sources :

Example 26 with BoundedContext

use of io.spine.server.BoundedContext in project core-java by SpineEventEngine.

the class ProjectionRepositoryShould method skip_all_the_events_after_catch_up_outdated.

// Due to mockito matcher usage
@SuppressWarnings("unchecked")
@Test
public void skip_all_the_events_after_catch_up_outdated() throws InterruptedException {
    // Set up bounded context
    final BoundedContext boundedContext = TestBoundedContextFactory.MultiTenant.newBoundedContext();
    final int eventsCount = 10;
    final EventStore eventStore = boundedContext.getEventBus().getEventStore();
    for (int i = 0; i < eventsCount; i++) {
        final ProjectId projectId = ProjectId.newBuilder().setId(valueOf(i)).build();
        final Message eventMessage = ProjectCreated.newBuilder().setProjectId(projectId).build();
        final Event event = createEvent(pack(projectId), eventMessage);
        appendEvent(eventStore, event);
    }
    // Set up repository
    final Duration duration = Durations2.nanos(1L);
    final ProjectionRepository repository = spy(new ManualCatchupProjectionRepository(boundedContext, duration));
    repository.initStorage(storageFactory());
    repository.catchUp();
    // Check bulk write
    verify(repository, never()).store(any(Projection.class));
}
Also used : EventStore(io.spine.server.event.EventStore) Message(com.google.protobuf.Message) ProjectId(io.spine.test.projection.ProjectId) Event(io.spine.base.Event) MultiTenant.newBoundedContext(io.spine.testdata.TestBoundedContextFactory.MultiTenant.newBoundedContext) BoundedContext(io.spine.server.BoundedContext) Duration(com.google.protobuf.Duration) Test(org.junit.Test)

Aggregations

BoundedContext (io.spine.server.BoundedContext)26 Test (org.junit.Test)16 Before (org.junit.Before)5 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)4 StreamObserver (io.grpc.stub.StreamObserver)3 MemoizingObserver (io.spine.io.StreamObservers.MemoizingObserver)3 StreamObservers.memoizingObserver (io.spine.io.StreamObservers.memoizingObserver)3 StreamObservers.noOpObserver (io.spine.io.StreamObservers.noOpObserver)3 StandTestProjectionRepository (io.spine.server.stand.Given.StandTestProjectionRepository)3 NullPointerTester (com.google.common.testing.NullPointerTester)2 Any (com.google.protobuf.Any)2 Version (io.spine.base.Version)2 CommandEnvelope (io.spine.envelope.CommandEnvelope)2 CommandBus (io.spine.server.commandbus.CommandBus)2 EventStore (io.spine.server.event.EventStore)2 ProjectionRepository (io.spine.server.projection.ProjectionRepository)2 ProjectId (io.spine.test.projection.ProjectId)2 MultiTenant.newBoundedContext (io.spine.testdata.TestBoundedContextFactory.MultiTenant.newBoundedContext)2 TypeUrl (io.spine.type.TypeUrl)2 Executor (java.util.concurrent.Executor)2