use of io.spine.core.CommandValidationError in project core-java by SpineEventEngine.
the class CommandExpiredException method commandExpired.
/**
* Creates an instance of the command expired error.
*/
static Error commandExpired(Command command) {
final String format = "Scheduled command of type `%s` expired.";
final CommandValidationError errorCode = CommandValidationError.EXPIRED;
return createError(format, command, errorCode);
}
use of io.spine.core.CommandValidationError in project core-java by SpineEventEngine.
the class UnsupportedCommandException method unsupportedCommand.
/**
* Creates an instance of unsupported command error.
*/
private static Error unsupportedCommand(Command command) {
final String format = "Commands of the type `%s` are not supported.";
final CommandValidationError errorCode = CommandValidationError.UNSUPPORTED_COMMAND;
return createError(format, command, errorCode);
}
use of io.spine.core.CommandValidationError 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());
}
}
use of io.spine.core.CommandValidationError in project core-java by SpineEventEngine.
the class CommandException method createError.
protected static Error createError(String format, Command command, CommandValidationError errorCode) {
final Message commandMessage = CommandEnvelope.of(command).getMessage();
final String commandType = commandMessage.getDescriptorForType().getFullName();
final String errMsg = format(format, commandType);
final String descriptorName = CommandValidationError.getDescriptor().getFullName();
final Error.Builder error = Error.newBuilder().setType(descriptorName).setMessage(errMsg).setCode(errorCode.getNumber()).putAllAttributes(commandTypeAttribute(commandMessage));
return error.build();
}
Aggregations