use of io.spine.core.RejectionClass in project core-java by SpineEventEngine.
the class RejectionBusShould method unregister_subscribers.
@Test
public void unregister_subscribers() {
final RejectionSubscriber subscriberOne = new InvalidProjectNameSubscriber();
final RejectionSubscriber subscriberTwo = new InvalidProjectNameSubscriber();
rejectionBus.register(subscriberOne);
rejectionBus.register(subscriberTwo);
final RejectionClass rejectionClass = RejectionClass.of(InvalidProjectName.class);
rejectionBus.unregister(subscriberOne);
// Check that the 2nd subscriber with the same rejection subscriber method remains
// after the 1st subscriber unregisters.
final Collection<RejectionDispatcher<?>> subscribers = rejectionBus.getDispatchers(rejectionClass);
assertFalse(subscribers.contains(subscriberOne));
assertTrue(subscribers.contains(subscriberTwo));
// Check that after 2nd subscriber us unregisters he's no longer in
rejectionBus.unregister(subscriberTwo);
assertFalse(rejectionBus.getDispatchers(rejectionClass).contains(subscriberTwo));
}
use of io.spine.core.RejectionClass 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());
}
use of io.spine.core.RejectionClass 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));
}
use of io.spine.core.RejectionClass in project core-java by SpineEventEngine.
the class RejectionBusShould method register_rejection_subscriber.
@Test
public void register_rejection_subscriber() {
final RejectionSubscriber subscriberOne = new InvalidProjectNameSubscriber();
final RejectionSubscriber subscriberTwo = new InvalidProjectNameSubscriber();
rejectionBus.register(subscriberOne);
rejectionBus.register(subscriberTwo);
final RejectionClass rejectionClass = RejectionClass.of(InvalidProjectName.class);
assertTrue(rejectionBus.hasDispatchers(rejectionClass));
final Collection<RejectionDispatcher<?>> dispatchers = rejectionBus.getDispatchers(rejectionClass);
assertTrue(dispatchers.contains(subscriberOne));
assertTrue(dispatchers.contains(subscriberTwo));
}
Aggregations