use of io.spine.base.Failure in project core-java by SpineEventEngine.
the class FailureBusShould method call_subscriber_when_failure_posted.
@Test
public void call_subscriber_when_failure_posted() {
final InvalidProjectNameSubscriber subscriber = new InvalidProjectNameSubscriber();
final Failure failure = invalidProjectNameFailure();
failureBus.register(subscriber);
failureBus.post(failure);
final Failure handled = subscriber.getFailureHandled();
// Compare the content without command ID, which is different in the remembered
assertEquals(failure.getMessage(), handled.getMessage());
assertEquals(failure.getContext().getCommand().getMessage(), handled.getContext().getCommand().getMessage());
assertEquals(failure.getContext().getCommand().getContext(), handled.getContext().getCommand().getContext());
}
use of io.spine.base.Failure in project core-java by SpineEventEngine.
the class FailureBusShould method deliver_postponed_failure_to_dispatcher_using_configured_executor.
@Test
public void deliver_postponed_failure_to_dispatcher_using_configured_executor() {
final BareDispatcher dispatcher = new BareDispatcher();
failureBusWithPostponedExecution.register(dispatcher);
final Failure failure = invalidProjectNameFailure();
failureBusWithPostponedExecution.post(failure);
final Set<FailureEnvelope> postponedFailures = postponedDelivery.getPostponedFailures();
final FailureEnvelope postponedFailure = postponedFailures.iterator().next();
verify(delegateDispatcherExecutor, never()).execute(any(Runnable.class));
postponedDelivery.deliverNow(postponedFailure, dispatcher.getClass());
assertTrue(dispatcher.isDispatchCalled());
verify(delegateDispatcherExecutor).execute(any(Runnable.class));
}
use of io.spine.base.Failure in project core-java by SpineEventEngine.
the class FailureBusShould method not_call_dispatchers_if_dispatcher_failure_execution_postponed.
@Test
public void not_call_dispatchers_if_dispatcher_failure_execution_postponed() {
final BareDispatcher dispatcher = new BareDispatcher();
failureBusWithPostponedExecution.register(dispatcher);
final Failure failure = invalidProjectNameFailure();
failureBusWithPostponedExecution.post(failure);
assertFalse(dispatcher.isDispatchCalled());
final boolean failurePostponed = postponedDelivery.isPostponed(failure, dispatcher);
assertTrue(failurePostponed);
}
use of io.spine.base.Failure in project core-java by SpineEventEngine.
the class FailureBusShould method not_enrich_failure_messages.
// as the FailureBus instances do not support enrichment yet.
@Test
public void not_enrich_failure_messages() {
final Failure original = Failure.getDefaultInstance();
final Failure enriched = failureBus.enrich(original);
assertEquals(original, enriched);
}
use of io.spine.base.Failure in project core-java by SpineEventEngine.
the class FailureEnvelopeShould method setUp.
@Before
public void setUp() {
this.commandMessage = Int32Value.getDefaultInstance();
this.command = requestFactory.command().create(commandMessage);
this.failureMessage = CannotPerformBusinessOperation.newBuilder().setOperationId(Identifiers.newUuid()).build();
final Failure failure = Failures.createFailure(failureMessage, command);
this.envelope = FailureEnvelope.of(failure);
}
Aggregations