Search in sources :

Example 1 with RejectionSubscriber

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

the class IntegrationBusTestEnv method contextWithExternalSubscribers.

public static BoundedContext contextWithExternalSubscribers(TransportFactory transportFactory) {
    final BoundedContext boundedContext = contextWithTransport(transportFactory);
    final EventSubscriber eventSubscriber = new ProjectEventsSubscriber();
    boundedContext.getIntegrationBus().register(eventSubscriber);
    boundedContext.getEventBus().register(eventSubscriber);
    final RejectionSubscriber rejectionSubscriber = new ProjectRejectionsExtSubscriber();
    boundedContext.getRejectionBus().register(rejectionSubscriber);
    boundedContext.getIntegrationBus().register(rejectionSubscriber);
    boundedContext.register(new ProjectCountAggregateRepository());
    boundedContext.register(new ProjectWizardRepository());
    return boundedContext;
}
Also used : EventSubscriber(io.spine.server.event.EventSubscriber) RejectionSubscriber(io.spine.server.rejection.RejectionSubscriber) BoundedContext(io.spine.server.BoundedContext)

Example 2 with RejectionSubscriber

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

the class IntegrationBusShould method throw_on_mismatch_of_external_attribute_during_dispatching.

@Test
public void throw_on_mismatch_of_external_attribute_during_dispatching() {
    final InMemoryTransportFactory transportFactory = InMemoryTransportFactory.newInstance();
    final BoundedContext sourceContext = contextWithTransport(transportFactory);
    final RejectionSubscriber rejectionSubscriber = new ExternalMismatchSubscriber();
    sourceContext.getRejectionBus().register(rejectionSubscriber);
    sourceContext.getIntegrationBus().register(rejectionSubscriber);
    final Rejection rejection = cannotStartArchivedProject();
    try {
        sourceContext.getRejectionBus().post(rejection);
        fail("An exception is expected.");
    } catch (Exception e) {
        final String exceptionMsg = e.getMessage();
        assertContains("external", exceptionMsg);
    }
}
Also used : Rejection(io.spine.core.Rejection) RejectionSubscriber(io.spine.server.rejection.RejectionSubscriber) ExternalMismatchSubscriber(io.spine.server.integration.given.IntegrationBusTestEnv.ExternalMismatchSubscriber) InMemoryTransportFactory(io.spine.server.integration.memory.InMemoryTransportFactory) BoundedContext(io.spine.server.BoundedContext) Test(org.junit.Test)

Aggregations

BoundedContext (io.spine.server.BoundedContext)2 RejectionSubscriber (io.spine.server.rejection.RejectionSubscriber)2 Rejection (io.spine.core.Rejection)1 EventSubscriber (io.spine.server.event.EventSubscriber)1 ExternalMismatchSubscriber (io.spine.server.integration.given.IntegrationBusTestEnv.ExternalMismatchSubscriber)1 InMemoryTransportFactory (io.spine.server.integration.memory.InMemoryTransportFactory)1 Test (org.junit.Test)1