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());
}
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));
}
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));
}
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);
}
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());
}
Aggregations