Search in sources :

Example 1 with InvalidProjectNameDelegate

use of io.spine.server.rejection.given.InvalidProjectNameDelegate 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());
}
Also used : AnotherInvalidProjectNameDelegate(io.spine.server.rejection.given.AnotherInvalidProjectNameDelegate) Given.missingOwnerRejection(io.spine.server.rejection.given.Given.missingOwnerRejection) Rejection(io.spine.core.Rejection) Given.invalidProjectNameRejection(io.spine.server.rejection.given.Given.invalidProjectNameRejection) InvalidProjectNameDelegate(io.spine.server.rejection.given.InvalidProjectNameDelegate) AnotherInvalidProjectNameDelegate(io.spine.server.rejection.given.AnotherInvalidProjectNameDelegate) RejectionEnvelope(io.spine.core.RejectionEnvelope) Test(org.junit.Test)

Aggregations

Rejection (io.spine.core.Rejection)1 RejectionEnvelope (io.spine.core.RejectionEnvelope)1 AnotherInvalidProjectNameDelegate (io.spine.server.rejection.given.AnotherInvalidProjectNameDelegate)1 Given.invalidProjectNameRejection (io.spine.server.rejection.given.Given.invalidProjectNameRejection)1 Given.missingOwnerRejection (io.spine.server.rejection.given.Given.missingOwnerRejection)1 InvalidProjectNameDelegate (io.spine.server.rejection.given.InvalidProjectNameDelegate)1 Test (org.junit.Test)1