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