use of io.spine.server.rejection.given.AnotherInvalidProjectNameDelegate in project core-java by SpineEventEngine.
the class RejectionBusShould method pick_proper_consumer_by_consumer_id_when_delivering_to_delegates_of_same_rejection.
@Test
public void pick_proper_consumer_by_consumer_id_when_delivering_to_delegates_of_same_rejection() {
final InvalidProjectNameDelegate first = new InvalidProjectNameDelegate();
final AnotherInvalidProjectNameDelegate second = new AnotherInvalidProjectNameDelegate();
final DelegatingRejectionDispatcher<String> firstDispatcher = DelegatingRejectionDispatcher.of(first);
final DelegatingRejectionDispatcher<String> secondDispatcher = DelegatingRejectionDispatcher.of(second);
rejectionBusWithPostponedExecution.register(firstDispatcher);
rejectionBusWithPostponedExecution.register(secondDispatcher);
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(firstDispatcher));
assertTrue(first.isDispatchCalled());
verify(delegateDispatcherExecutor).execute(any(Runnable.class));
assertFalse(second.isDispatchCalled());
}
Aggregations