use of io.spine.core.Status in project core-java by SpineEventEngine.
the class DuplicateCommandShould method not_be_acknowledged_on_client_when_not_sent.
@Test
public void not_be_acknowledged_on_client_when_not_sent() {
final TenantId tenantId = newTenantId();
final Command command = command(createProject(), tenantId);
final Ack ack = client.post(command);
final Status status = ack.getStatus();
assertTrue(status.hasOk());
}
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 error 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, Error cause) {
checkNotNull(cause);
checkArgument(isNotDefault(cause));
final Status status = Status.newBuilder().setError(cause).build();
return setStatus(id, status);
}
use of io.spine.core.Status in project core-java by SpineEventEngine.
the class CommandServiceShould method return_error_status_if_command_is_unsupported.
@Test
public void return_error_status_if_command_is_unsupported() {
final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
final Command unsupportedCmd = factory.createCommand(StringValue.getDefaultInstance());
service.post(unsupportedCmd, responseObserver);
assertTrue(responseObserver.isCompleted());
final Ack result = responseObserver.firstResponse();
assertNotNull(result);
assertTrue(isNotDefault(result));
final Status status = result.getStatus();
assertEquals(ERROR, status.getStatusCase());
final Error error = status.getError();
assertEquals(CommandValidationError.getDescriptor().getFullName(), error.getType());
}
use of io.spine.core.Status in project core-java by SpineEventEngine.
the class AbstractCommandRouter method checkSent.
private static void checkSent(Command command, Ack ack) {
final Status status = ack.getStatus();
final CommandId routedCommandId = unpack(ack.getMessageId());
final CommandId commandId = command.getId();
checkState(commandId.equals(routedCommandId), "Unexpected command posted. Intending (%s) but was (%s).", commandId, routedCommandId);
checkState(status.getStatusCase() == Status.StatusCase.OK, "Command posting failed with status: %s.", status);
}
use of io.spine.core.Status in project core-java by SpineEventEngine.
the class DuplicateCommandShould method be_acknowledged_on_client_when_posted_to_an_aggregate.
@Test
public void be_acknowledged_on_client_when_posted_to_an_aggregate() {
final TenantId tenantId = newTenantId();
final Command command = command(createProject(), tenantId);
client.post(command);
final Ack ack = client.post(command);
final Status status = ack.getStatus();
final Error error = status.getError();
final String errorType = error.getType();
final String expectedErrorType = DuplicateCommandException.class.getCanonicalName();
assertEquals(expectedErrorType, errorType);
}
Aggregations