use of io.spine.core.RejectionEnvelope in project core-java by SpineEventEngine.
the class ProcessManagerShould method dispatch_rejection_by_rejection_and_command_message.
@Test
public void dispatch_rejection_by_rejection_and_command_message() {
final RejectionEnvelope rejection = entityAlreadyArchived(PmAddTask.class);
dispatch(processManager, rejection);
assertEquals(AnyPacker.pack(rejection.getCommandMessage()), processManager.getState());
}
use of io.spine.core.RejectionEnvelope in project core-java by SpineEventEngine.
the class ProcessManagerShould method dispatch_rejection_by_rejection_message_only.
@Test
public void dispatch_rejection_by_rejection_message_only() {
final RejectionEnvelope rejection = entityAlreadyArchived(StringValue.class);
dispatch(processManager, rejection);
assertEquals(rejection.getOuterObject().getMessage(), processManager.getState());
}
use of io.spine.core.RejectionEnvelope 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());
}
use of io.spine.core.RejectionEnvelope in project core-java by SpineEventEngine.
the class PostponedDispatcherRejectionDelivery method isPostponed.
public boolean isPostponed(Rejection rejection, RejectionDispatcher<?> dispatcher) {
final RejectionEnvelope envelope = RejectionEnvelope.of(rejection);
final Class<? extends RejectionDispatcher> actualClass = postponedExecutions.get(envelope);
final boolean rejectionPostponed = actualClass != null;
final boolean dispatcherMatches = rejectionPostponed && dispatcher.getClass().equals(actualClass);
return dispatcherMatches;
}
Aggregations