use of io.spine.core.Ack in project core-java by SpineEventEngine.
the class BoundedContextShould method not_notify_integration_event_subscriber_if_event_is_invalid.
@Test
public void not_notify_integration_event_subscriber_if_event_is_invalid() {
final BoundedContext boundedContext = BoundedContext.newBuilder().setMultitenant(true).build();
// Unsupported message.
final Any invalidMsg = AnyPacker.pack(BcProjectCreated.getDefaultInstance());
final IntegrationEvent event = Given.AnIntegrationEvent.projectCreated().toBuilder().setMessage(invalidMsg).build();
final MemoizingObserver<Ack> observer = memoizingObserver();
boundedContext.notify(event, observer);
assertEquals(ERROR, observer.firstResponse().getStatus().getStatusCase());
}
use of io.spine.core.Ack 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);
}
use of io.spine.core.Ack in project core-java by SpineEventEngine.
the class Buses method setStatus.
private static Ack setStatus(Message id, Status status) {
checkNotNull(id);
final Any packedId = pack(id);
final Ack result = Ack.newBuilder().setMessageId(packedId).setStatus(status).build();
return result;
}
use of io.spine.core.Ack in project core-java by SpineEventEngine.
the class TestClient method post.
/**
* Creates a command for the passed message and sends it to the server.
*/
@CanIgnoreReturnValue
public Optional<Ack> post(CommandMessage domainCommand) {
var command = requestFactory.command().create(domainCommand);
var commandType = TypeName.of(domainCommand);
Ack result = null;
try {
_debug().log("Sending command: `%s` ...", commandType);
result = commandClient.post(command);
_debug().log("Ack: `%s`.", result);
} catch (RuntimeException e) {
_warn().withCause(e).log(RPC_FAILED);
}
return Optional.ofNullable(result);
}
Aggregations