Search in sources :

Example 1 with BareDispatcher

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

the class RejectionBusShould method call_dispatchers.

@Test
public void call_dispatchers() {
    final BareDispatcher dispatcher = new BareDispatcher();
    rejectionBus.register(dispatcher);
    rejectionBus.post(invalidProjectNameRejection());
    assertTrue(dispatcher.isDispatchCalled());
}
Also used : BareDispatcher(io.spine.server.rejection.given.BareDispatcher) Test(org.junit.Test)

Example 2 with BareDispatcher

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

the class RejectionBusShould method deliver_postponed_rejection_to_dispatcher_using_configured_executor.

@Test
public void deliver_postponed_rejection_to_dispatcher_using_configured_executor() {
    final BareDispatcher dispatcher = new BareDispatcher();
    rejectionBusWithPostponedExecution.register(dispatcher);
    final Rejection rejection = invalidProjectNameRejection();
    rejectionBusWithPostponedExecution.post(rejection);
    final Set<RejectionEnvelope> postponedRejections = postponedDelivery.getPostponedRejections();
    final RejectionEnvelope postponedRejection = postponedRejections.iterator().next();
    verify(delegateDispatcherExecutor, never()).execute(any(Runnable.class));
    postponedDelivery.deliverNow(postponedRejection, Consumers.idOf(dispatcher));
    assertTrue(dispatcher.isDispatchCalled());
    verify(delegateDispatcherExecutor).execute(any(Runnable.class));
}
Also used : Given.missingOwnerRejection(io.spine.server.rejection.given.Given.missingOwnerRejection) Rejection(io.spine.core.Rejection) Given.invalidProjectNameRejection(io.spine.server.rejection.given.Given.invalidProjectNameRejection) BareDispatcher(io.spine.server.rejection.given.BareDispatcher) RejectionEnvelope(io.spine.core.RejectionEnvelope) Test(org.junit.Test)

Example 3 with BareDispatcher

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

the class RejectionBusShould method register_dispatchers.

@Test
public void register_dispatchers() {
    final RejectionDispatcher<?> dispatcher = new BareDispatcher();
    rejectionBus.register(dispatcher);
    final RejectionClass rejectionClass = RejectionClass.of(InvalidProjectName.class);
    assertTrue(rejectionBus.getDispatchers(rejectionClass).contains(dispatcher));
}
Also used : RejectionClass(io.spine.core.RejectionClass) BareDispatcher(io.spine.server.rejection.given.BareDispatcher) Test(org.junit.Test)

Example 4 with BareDispatcher

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

the class RejectionBusShould method not_call_dispatchers_if_dispatcher_rejection_execution_postponed.

@Test
public void not_call_dispatchers_if_dispatcher_rejection_execution_postponed() {
    final BareDispatcher dispatcher = new BareDispatcher();
    rejectionBusWithPostponedExecution.register(dispatcher);
    final Rejection rejection = invalidProjectNameRejection();
    rejectionBusWithPostponedExecution.post(rejection);
    assertFalse(dispatcher.isDispatchCalled());
    final boolean rejectionPostponed = postponedDelivery.isPostponed(rejection, dispatcher);
    assertTrue(rejectionPostponed);
}
Also used : Given.missingOwnerRejection(io.spine.server.rejection.given.Given.missingOwnerRejection) Rejection(io.spine.core.Rejection) Given.invalidProjectNameRejection(io.spine.server.rejection.given.Given.invalidProjectNameRejection) BareDispatcher(io.spine.server.rejection.given.BareDispatcher) Test(org.junit.Test)

Example 5 with BareDispatcher

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

the class RejectionBusShould method unregister_registries_on_close.

@Test
public void unregister_registries_on_close() throws Exception {
    final RejectionBus rejectionBus = RejectionBus.newBuilder().build();
    rejectionBus.register(new BareDispatcher());
    rejectionBus.register(new InvalidProjectNameSubscriber());
    final RejectionClass rejectionClass = RejectionClass.of(InvalidProjectName.class);
    rejectionBus.close();
    assertTrue(rejectionBus.getDispatchers(rejectionClass).isEmpty());
}
Also used : RejectionClass(io.spine.core.RejectionClass) BareDispatcher(io.spine.server.rejection.given.BareDispatcher) InvalidProjectNameSubscriber(io.spine.server.rejection.given.InvalidProjectNameSubscriber) Test(org.junit.Test)

Aggregations

BareDispatcher (io.spine.server.rejection.given.BareDispatcher)6 Test (org.junit.Test)6 RejectionClass (io.spine.core.RejectionClass)3 Rejection (io.spine.core.Rejection)2 Given.invalidProjectNameRejection (io.spine.server.rejection.given.Given.invalidProjectNameRejection)2 Given.missingOwnerRejection (io.spine.server.rejection.given.Given.missingOwnerRejection)2 RejectionEnvelope (io.spine.core.RejectionEnvelope)1 InvalidProjectNameSubscriber (io.spine.server.rejection.given.InvalidProjectNameSubscriber)1