use of io.spine.core.CommandEnvelope in project core-java by SpineEventEngine.
the class AggregateCommandEndpointShould method assertDispatches.
/*
* Utility methods.
****************************/
private void assertDispatches(Command cmd) {
final CommandEnvelope envelope = CommandEnvelope.of(cmd);
repository.dispatch(envelope);
ProjectAggregate.assertHandled(cmd);
}
use of io.spine.core.CommandEnvelope in project core-java by SpineEventEngine.
the class AggregateRepositoryShould method not_pass_command_rejection_to_onError.
@Test
public void not_pass_command_rejection_to_onError() {
final FailingAggregateRepository repository = new FailingAggregateRepository();
boundedContext.register(repository);
final TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(getClass());
// Passing negative long value to `FailingAggregate` should cause a rejection.
final CommandEnvelope ce = CommandEnvelope.of(requestFactory.createCommand(UInt64Value.newBuilder().setValue(-100_000_000L).build()));
boundedContext.getCommandBus().post(ce.getCommand(), StreamObservers.<Ack>noOpObserver());
assertFalse(repository.isErrorLogged());
}
use of io.spine.core.CommandEnvelope in project core-java by SpineEventEngine.
the class ProcessManagerShould method throw_exception_if_dispatch_unknown_command.
@Test(expected = IllegalStateException.class)
public void throw_exception_if_dispatch_unknown_command() {
final Int32Value unknownCommand = Int32Value.getDefaultInstance();
final CommandEnvelope envelope = CommandEnvelope.of(requestFactory.createCommand(unknownCommand));
processManager.dispatchCommand(envelope);
}
use of io.spine.core.CommandEnvelope in project core-java by SpineEventEngine.
the class PmCommandEndpoint method getTargets.
@Override
protected I getTargets() {
final CommandEnvelope envelope = envelope();
final I id = repository().getCommandRouting().apply(envelope.getMessage(), envelope.getCommandContext());
return id;
}
use of io.spine.core.CommandEnvelope in project core-java by SpineEventEngine.
the class TestActorRequestFactory method generateEnvelope.
/**
* Generates a command and wraps it into envelope.
*/
public CommandEnvelope generateEnvelope() {
final Command command = generateCommand();
final CommandEnvelope result = CommandEnvelope.of(command);
return result;
}
Aggregations