Search in sources :

Example 11 with InMemoryTransportFactory

use of io.spine.server.integration.memory.InMemoryTransportFactory 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 12 with InMemoryTransportFactory

use of io.spine.server.integration.memory.InMemoryTransportFactory 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)

Aggregations

BoundedContext (io.spine.server.BoundedContext)12 InMemoryTransportFactory (io.spine.server.integration.memory.InMemoryTransportFactory)12 Test (org.junit.Test)12 Event (io.spine.core.Event)9 Rejection (io.spine.core.Rejection)3 EventBus (io.spine.server.event.EventBus)3 Message (com.google.protobuf.Message)2 BoundedContextName (io.spine.core.BoundedContextName)2 ProjectEventsSubscriber (io.spine.server.integration.given.IntegrationBusTestEnv.ProjectEventsSubscriber)2 Error (io.spine.base.Error)1 Ack (io.spine.core.Ack)1 ExternalMismatchSubscriber (io.spine.server.integration.given.IntegrationBusTestEnv.ExternalMismatchSubscriber)1 ProjectRejectionsExtSubscriber (io.spine.server.integration.given.IntegrationBusTestEnv.ProjectRejectionsExtSubscriber)1 ProjectStartedExtSubscriber (io.spine.server.integration.given.IntegrationBusTestEnv.ProjectStartedExtSubscriber)1 RejectionBus (io.spine.server.rejection.RejectionBus)1 RejectionSubscriber (io.spine.server.rejection.RejectionSubscriber)1