use of io.spine.base.Failure in project core-java by SpineEventEngine.
the class FailureClass method of.
/**
* Creates a new instance of the failure class by passed failure instance.
*
* <p>If an instance of {@link Failure} (which implements {@code Message}) is passed to this
* method, enclosing failure message will be un-wrapped to determine the class of the failure.
*
* @param failure a failure instance
* @return new instance
*/
public static FailureClass of(Message failure) {
final Message message = checkNotNull(failure);
if (message instanceof Failure) {
final Failure failureRecord = (Failure) failure;
final Message enclosed = Failures.getMessage(failureRecord);
return of(enclosed.getClass());
}
final FailureClass result = of(message.getClass());
return result;
}
use of io.spine.base.Failure in project core-java by SpineEventEngine.
the class SingleTenantCommandBusShould method propagate_failures_to_failure_bus.
@Test
public void propagate_failures_to_failure_bus() {
final FaultyHandler faultyHandler = new FaultyHandler(eventBus);
commandBus.register(faultyHandler);
final Command addTaskCommand = clearTenantId(addTask());
commandBus.post(addTaskCommand, StreamObservers.<Response>noOpObserver());
final InvalidProjectName failureThrowable = faultyHandler.getThrowable();
final Failure expectedFailure = failureThrowable.toFailure(addTaskCommand);
verify(failureBus).post(eq(expectedFailure), ArgumentMatchers.<StreamObserver<Response>>any());
}
use of io.spine.base.Failure in project core-java by SpineEventEngine.
the class StorageShould method set_failure_command_status.
// We get right after we update status.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void set_failure_command_status() {
givenNewRecord();
final Failure failure = newFailure();
storage.updateStatus(id, failure);
final CommandRecord actual = read(id).get();
assertEquals(FAILURE, actual.getStatus().getCode());
assertEquals(failure, actual.getStatus().getFailure());
}
Aggregations