Search in sources :

Example 6 with BareDispatcher

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

the class RejectionBusShould method unregister_dispatchers.

@Test
public void unregister_dispatchers() {
    final RejectionDispatcher<?> dispatcherOne = new BareDispatcher();
    final RejectionDispatcher<?> dispatcherTwo = new BareDispatcher();
    final RejectionClass rejectionClass = RejectionClass.of(InvalidProjectName.class);
    rejectionBus.register(dispatcherOne);
    rejectionBus.register(dispatcherTwo);
    rejectionBus.unregister(dispatcherOne);
    final Set<RejectionDispatcher<?>> dispatchers = rejectionBus.getDispatchers(rejectionClass);
    // Check we don't have 1st dispatcher, but have 2nd.
    assertFalse(dispatchers.contains(dispatcherOne));
    assertTrue(dispatchers.contains(dispatcherTwo));
    rejectionBus.unregister(dispatcherTwo);
    assertFalse(rejectionBus.getDispatchers(rejectionClass).contains(dispatcherTwo));
}
Also used : RejectionClass(io.spine.core.RejectionClass) BareDispatcher(io.spine.server.rejection.given.BareDispatcher) 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