use of io.spine.core.CommandContext in project core-java by SpineEventEngine.
the class RejectionSubscriberMethodShould method invoke_subscriber_method.
@Test
public void invoke_subscriber_method() throws InvocationTargetException {
final ValidThreeParams subscriberObject = new ValidThreeParams();
final RejectionSubscriberMethod method = new RejectionSubscriberMethod(subscriberObject.getMethod());
final InvalidProjectName rejectionMessage = Given.RejectionMessage.invalidProjectName();
final RejectionContext.Builder builder = RejectionContext.newBuilder();
final CommandContext commandContext = CommandContext.newBuilder().setTargetVersion(1020).build();
final RjUpdateProjectName commandMessage = RjUpdateProjectName.getDefaultInstance();
builder.setCommand(Command.newBuilder().setMessage(pack(commandMessage)).setContext(commandContext));
final RejectionContext rejectionContext = builder.build();
method.invoke(subscriberObject, rejectionMessage, rejectionContext);
assertEquals(rejectionMessage, subscriberObject.getLastRejectionMessage());
assertEquals(commandMessage, subscriberObject.getLastCommandMessage());
assertEquals(commandContext, subscriberObject.getLastCommandContext());
}
use of io.spine.core.CommandContext in project core-java by SpineEventEngine.
the class EventsTestEnv method commandContext.
public static CommandContext commandContext(TenantId id) {
final ActorContext actorContext = ActorContext.newBuilder().setTenantId(id).build();
final CommandContext result = CommandContext.newBuilder().setActorContext(actorContext).build();
return result;
}
use of io.spine.core.CommandContext in project core-java by SpineEventEngine.
the class AbstractCommandRouter method produceCommand.
private Command produceCommand(Message commandMessage) {
final CommandContext sourceContext = source.getContext();
final CommandFactory commandFactory = commandFactory(sourceContext);
final Command result = commandFactory.createBasedOnContext(commandMessage, sourceContext);
return result;
}
use of io.spine.core.CommandContext in project core-java by SpineEventEngine.
the class CommandHistory method contains.
public boolean contains(Command command) {
final Message message = Commands.getMessage(command);
if (messages.contains(message)) {
final int messageIndex = messages.indexOf(message);
final CommandContext actualContext = command.getContext();
final CommandContext storedContext = contexts.get(messageIndex);
return actualContext.equals(storedContext);
}
return false;
}
use of io.spine.core.CommandContext in project core-java by SpineEventEngine.
the class TestActorRequestFactory method withTimestamp.
private static Command withTimestamp(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();
}
Aggregations