Search in sources :

Example 6 with Status

use of io.spine.core.Status in project core-java by SpineEventEngine.

the class AbstractCommandBusTestSuite method checkCommandError.

static void checkCommandError(Ack sendingResult, CommandValidationError validationError, String errorType, Command cmd) {
    final Status status = sendingResult.getStatus();
    assertEquals(status.getStatusCase(), Status.StatusCase.ERROR);
    final CommandId commandId = cmd.getId();
    assertEquals(commandId, unpack(sendingResult.getMessageId()));
    final Error error = status.getError();
    assertEquals(errorType, error.getType());
    assertEquals(validationError.getNumber(), error.getCode());
    assertFalse(error.getMessage().isEmpty());
    if (validationError == INVALID_COMMAND) {
        assertFalse(error.getValidationError().getConstraintViolationList().isEmpty());
    }
}
Also used : Status(io.spine.core.Status) Error(io.spine.base.Error) CommandValidationError(io.spine.core.CommandValidationError) CommandId(io.spine.core.CommandId)

Example 7 with Status

use of io.spine.core.Status in project core-java by SpineEventEngine.

the class Buses method reject.

/**
 * Creates {@code Ack} response for the given message ID with the rejection status.
 *
 * @param id    the ID of the message to provide with the status
 * @param cause the cause of the message rejection
 * @return the {@code Ack} response with the given message ID
 */
public static Ack reject(Message id, Rejection cause) {
    checkNotNull(cause);
    checkArgument(isNotDefault(cause));
    final Status status = Status.newBuilder().setRejection(cause).build();
    return setStatus(id, status);
}
Also used : Status(io.spine.core.Status)

Aggregations

Status (io.spine.core.Status)7 Error (io.spine.base.Error)3 Ack (io.spine.core.Ack)3 Command (io.spine.core.Command)3 Test (org.junit.Test)3 CommandId (io.spine.core.CommandId)2 CommandValidationError (io.spine.core.CommandValidationError)2 TenantId (io.spine.core.TenantId)2 DuplicateCommandTestEnv.newTenantId (io.spine.server.command.given.DuplicateCommandTestEnv.newTenantId)2 TestActorRequestFactory (io.spine.client.TestActorRequestFactory)1