Search in sources :

Example 46 with BoundedContext

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

the class IntegrationBusShould method dispatch_rejections_from_one_BC_to_external_subscribers_of_another_BC.

@Test
public void dispatch_rejections_from_one_BC_to_external_subscribers_of_another_BC() {
    final InMemoryTransportFactory transportFactory = InMemoryTransportFactory.newInstance();
    final BoundedContext sourceContext = contextWithTransport(transportFactory);
    contextWithExternalSubscribers(transportFactory);
    assertNull(ProjectRejectionsExtSubscriber.getExternalRejection());
    assertNull(ProjectCountAggregate.getExternalRejection());
    assertNull(ProjectWizard.getExternalRejection());
    final Rejection rejection = cannotStartArchivedProject();
    sourceContext.getRejectionBus().post(rejection);
    final Message rejectionMessage = AnyPacker.unpack(rejection.getMessage());
    assertEquals(rejectionMessage, ProjectRejectionsExtSubscriber.getExternalRejection());
    assertEquals(rejectionMessage, ProjectCountAggregate.getExternalRejection());
    assertEquals(rejectionMessage, ProjectWizard.getExternalRejection());
}
Also used : Rejection(io.spine.core.Rejection) Message(com.google.protobuf.Message) InMemoryTransportFactory(io.spine.server.integration.memory.InMemoryTransportFactory) BoundedContext(io.spine.server.BoundedContext) Test(org.junit.Test)

Example 47 with BoundedContext

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

the class IntegrationBusShould method avoid_dispatching_events_from_one_BC_to_domestic_entity_subscribers_of_another_BC.

@Test
public void avoid_dispatching_events_from_one_BC_to_domestic_entity_subscribers_of_another_BC() {
    final InMemoryTransportFactory transportFactory = InMemoryTransportFactory.newInstance();
    final BoundedContext sourceContext = contextWithTransport(transportFactory);
    final BoundedContext destContext = contextWithExtEntitySubscribers(transportFactory);
    assertNull(ProjectDetails.getDomesticEvent());
    final Event event = projectStarted();
    sourceContext.getEventBus().post(event);
    assertNotEquals(AnyPacker.unpack(event.getMessage()), ProjectDetails.getDomesticEvent());
    assertNull(ProjectDetails.getDomesticEvent());
    destContext.getEventBus().post(event);
    assertEquals(AnyPacker.unpack(event.getMessage()), ProjectDetails.getDomesticEvent());
}
Also used : InMemoryTransportFactory(io.spine.server.integration.memory.InMemoryTransportFactory) Event(io.spine.core.Event) BoundedContext(io.spine.server.BoundedContext) Test(org.junit.Test)

Example 48 with BoundedContext

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

the class IntegrationBusTestEnv method contextWithProjectCreatedNeeds.

public static BoundedContext contextWithProjectCreatedNeeds(TransportFactory factory) {
    final BoundedContext result = contextWithTransport(factory);
    result.getIntegrationBus().register(new ProjectEventsSubscriber());
    return result;
}
Also used : BoundedContext(io.spine.server.BoundedContext)

Example 49 with BoundedContext

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

the class IntegrationBusTestEnv method contextWithContextAwareEntitySubscriber.

public static BoundedContext contextWithContextAwareEntitySubscriber(TransportFactory transportFactory) {
    final BoundedContext boundedContext = contextWithTransport(transportFactory);
    boundedContext.register(new ContextAwareProjectDetailsRepository());
    return boundedContext;
}
Also used : BoundedContext(io.spine.server.BoundedContext)

Example 50 with BoundedContext

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

the class IntegrationBusTestEnv method contextWithProjectStartedNeeds.

public static BoundedContext contextWithProjectStartedNeeds(TransportFactory factory) {
    final BoundedContext result = contextWithTransport(factory);
    result.getIntegrationBus().register(new ProjectStartedExtSubscriber());
    return result;
}
Also used : BoundedContext(io.spine.server.BoundedContext)

Aggregations

BoundedContext (io.spine.server.BoundedContext)58 Test (org.junit.Test)34 Event (io.spine.core.Event)12 InMemoryTransportFactory (io.spine.server.integration.memory.InMemoryTransportFactory)12 Before (org.junit.Before)9 Rejection (io.spine.core.Rejection)6 Ack (io.spine.core.Ack)5 Message (com.google.protobuf.Message)4 Error (io.spine.base.Error)4 TypeUrl (io.spine.type.TypeUrl)4 Any (com.google.protobuf.Any)3 StringValue (com.google.protobuf.StringValue)3 Command (io.spine.core.Command)3 CommandEnvelope (io.spine.core.CommandEnvelope)3 TenantId (io.spine.core.TenantId)3 CustomerAggregateRepository (io.spine.server.Given.CustomerAggregateRepository)3 EventBus (io.spine.server.event.EventBus)3 StandTestProjectionRepository (io.spine.server.stand.Given.StandTestProjectionRepository)3 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)3 NullPointerTester (com.google.common.testing.NullPointerTester)2