use of io.spine.core.Command 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.Command in project core-java by SpineEventEngine.
the class AbstractCommandBusTestSuite method storeAsScheduled.
void storeAsScheduled(Iterable<Command> commands, Duration delay, Timestamp schedulingTime) {
for (Command cmd : commands) {
final Command cmdWithSchedule = setSchedule(cmd, delay, schedulingTime);
commandStore.store(cmdWithSchedule, SCHEDULED);
}
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class AbstractCommandBusTestSuite method newCommandWithoutContext.
static Command newCommandWithoutContext() {
final Command cmd = createProject();
final Command invalidCmd = cmd.toBuilder().setContext(CommandContext.getDefaultInstance()).build();
return invalidCmd;
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class AbstractCommandBusTestSuite method clearTenantId.
protected static Command clearTenantId(Command cmd) {
final ActorContext.Builder withNoTenant = ActorContext.newBuilder().setTenantId(TenantId.getDefaultInstance());
final Command result = cmd.toBuilder().setContext(cmd.getContext().toBuilder().setActorContext(withNoTenant)).build();
return result;
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class AbstractCommandBusTestSuite method post_commands_in_bulk.
@Test
public void post_commands_in_bulk() {
final Command first = newCommand();
final Command second = newCommand();
final List<Command> commands = newArrayList(first, second);
// Some derived test suite classes may register the handler in setUp().
// This prevents the repeating registration (which is an illegal operation).
commandBus.unregister(createProjectHandler);
commandBus.register(createProjectHandler);
final CommandBus spy = spy(commandBus);
spy.post(commands, StreamObservers.<Ack>memoizingObserver());
@SuppressWarnings("unchecked") final ArgumentCaptor<Iterable<Command>> storingCaptor = forClass(Iterable.class);
verify(spy).store(storingCaptor.capture());
final Iterable<Command> storingArgs = storingCaptor.getValue();
assertSize(commands.size(), storingArgs);
assertContainsAll(storingArgs, first, second);
final ArgumentCaptor<CommandEnvelope> postingCaptor = forClass(CommandEnvelope.class);
verify(spy, times(2)).doPost(postingCaptor.capture());
final List<CommandEnvelope> postingArgs = postingCaptor.getAllValues();
assertSize(commands.size(), postingArgs);
assertEquals(commands.get(0), postingArgs.get(0).getCommand());
assertEquals(commands.get(1), postingArgs.get(1).getCommand());
commandBus.unregister(createProjectHandler);
}
Aggregations