use of io.spine.core.Ack in project core-java by SpineEventEngine.
the class AggregateShould method traverse_the_history_up_to_the_latest_snapshot.
@Test
public void traverse_the_history_up_to_the_latest_snapshot() {
repository.setSnapshotTrigger(3);
final TenantId tenantId = newTenantId();
final Command createCommand = command(createProject, tenantId);
final Command startCommand = command(startProject, tenantId);
final Command addTaskCommand = command(addTask, tenantId);
final Command addTaskCommand2 = command(addTask, tenantId);
final CommandBus commandBus = boundedContext.getCommandBus();
final StreamObserver<Ack> noOpObserver = noOpObserver();
commandBus.post(createCommand, noOpObserver);
commandBus.post(startCommand, noOpObserver);
commandBus.post(newArrayList(addTaskCommand, addTaskCommand2), noOpObserver);
final TestAggregate aggregate = repository.loadAggregate(tenantId, ID);
final Iterator<Event> history = aggregate.historyBackward();
assertEquals(addTaskCommand2.getId(), getRootCommandId(history.next()));
assertFalse(history.hasNext());
}
use of io.spine.core.Ack in project core-java by SpineEventEngine.
the class IdempotencyGuardShould method not_throw_if_another_command_was_handled.
@Test
public void not_throw_if_another_command_was_handled() {
final TenantId tenantId = newTenantId();
final ProjectId projectId = newProjectId();
final Command createCommand = command(createProject(projectId), tenantId);
final Command startCommand = command(startProject(projectId), tenantId);
final CommandBus commandBus = boundedContext.getCommandBus();
final StreamObserver<Ack> noOpObserver = noOpObserver();
commandBus.post(createCommand, noOpObserver);
final IgTestAggregate aggregate = repository.loadAggregate(tenantId, projectId);
final IdempotencyGuard guard = new IdempotencyGuard(aggregate);
guard.check(of(startCommand));
}
use of io.spine.core.Ack in project core-java by SpineEventEngine.
the class IdempotencyGuardShould method not_throw_when_the_command_was_handled_but_the_snapshot_was_made.
@Test
public void not_throw_when_the_command_was_handled_but_the_snapshot_was_made() {
repository.setSnapshotTrigger(1);
final TenantId tenantId = newTenantId();
final ProjectId projectId = newProjectId();
final Command createCommand = command(createProject(projectId), tenantId);
final CommandBus commandBus = boundedContext.getCommandBus();
final StreamObserver<Ack> noOpObserver = noOpObserver();
commandBus.post(createCommand, noOpObserver);
final IgTestAggregate aggregate = repository.loadAggregate(tenantId, projectId);
final IdempotencyGuard guard = new IdempotencyGuard(aggregate);
guard.check(of(createCommand));
}
use of io.spine.core.Ack in project core-java by SpineEventEngine.
the class BoundedContextShould method notify_integration_event_subscriber.
@Test
public void notify_integration_event_subscriber() {
registerAll();
final MemoizingObserver<Ack> observer = memoizingObserver();
final IntegrationEvent event = Given.AnIntegrationEvent.projectCreated();
final Message msg = unpack(event.getMessage());
boundedContext.notify(event, observer);
assertEquals(Responses.statusOk(), observer.firstResponse().getStatus());
assertEquals(subscriber.getHandledEvent(), msg);
}
use of io.spine.core.Ack 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());
}
Aggregations