use of io.spine.base.Command in project core-java by SpineEventEngine.
the class FailureSubscriber method dispatch.
@Override
public void dispatch(final FailureEnvelope envelope) {
final Command originCommand = envelope.getOuterObject().getContext().getCommand();
final CommandOperation op = new CommandOperation(originCommand) {
@Override
public void run() {
handle(envelope.getMessage(), envelope.getCommandMessage(), envelope.getCommandContext());
}
};
op.execute();
}
use of io.spine.base.Command in project core-java by SpineEventEngine.
the class TimeTests method adjustTimestamp.
/**
* Adjusts a timestamp in the context of the passed command.
*
* @return new command instance with the modified timestamp
*/
public static Command adjustTimestamp(Command command, Timestamp timestamp) {
final CommandContext context = command.getContext();
final ActorContext.Builder withTime = context.getActorContext().toBuilder().setTimestamp(timestamp);
final Command.Builder commandBuilder = command.toBuilder().setContext(context.toBuilder().setActorContext(withTime));
return commandBuilder.build();
}
use of io.spine.base.Command in project core-java by SpineEventEngine.
the class CommandTestShould method createAndAssertCommand.
/**
* Creates a new command and checks its content.
*
* <p>If the method completes, we assume that the passed command test
* has correctly working {@link ActorRequestFactory}.
*/
private static void createAndAssertCommand(CommandTest<StringValue> commandTest) {
final StringValue commandMessage = newUuidValue();
final Command command = commandTest.createCommand(commandMessage);
checkNotDefault(command);
assertEquals(commandMessage, Commands.getMessage(command));
checkNotDefault(command.getContext());
}
use of io.spine.base.Command in project core-java by SpineEventEngine.
the class CommandTestShould method create_different_command.
@Test
public void create_different_command() {
final Message anotherCommandMsg = Time.getCurrentTime();
final Command anotherCommand = commandTest.createDifferentCommand(anotherCommandMsg);
assertEquals(anotherCommandMsg, Commands.getMessage(anotherCommand));
}
use of io.spine.base.Command in project core-java by SpineEventEngine.
the class CommandTestShould method create_different_command_with_timestamp.
@Test
public void create_different_command_with_timestamp() {
final Message anotherCommandMsg = Time.getCurrentTime();
final Timestamp timestamp = TimeTests.Past.minutesAgo(30);
final Command anotherCommand = commandTest.createDifferentCommand(anotherCommandMsg, timestamp);
assertEquals(anotherCommandMsg, Commands.getMessage(anotherCommand));
assertEquals(timestamp, anotherCommand.getContext().getActorContext().getTimestamp());
}
Aggregations