use of io.spine.server.aggregate.given.aggregate.IgTestAggregate in project core-java by SpineEventEngine.
the class IdempotencyGuardShould method not_throw_if_the_command_was_not_handled.
@Test
public void not_throw_if_the_command_was_not_handled() {
final TenantId tenantId = newTenantId();
final ProjectId projectId = newProjectId();
final Command createCommand = command(createProject(projectId), tenantId);
final IgTestAggregate aggregate = new IgTestAggregate(projectId);
final IdempotencyGuard guard = new IdempotencyGuard(aggregate);
guard.check(of(createCommand));
}
use of io.spine.server.aggregate.given.aggregate.IgTestAggregate 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.server.aggregate.given.aggregate.IgTestAggregate 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.server.aggregate.given.aggregate.IgTestAggregate in project core-java by SpineEventEngine.
the class IdempotencyGuardShould method throw_DuplicateCommandException_when_the_command_was_handled_since_last_snapshot.
@Test(expected = DuplicateCommandException.class)
public void throw_DuplicateCommandException_when_the_command_was_handled_since_last_snapshot() {
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));
}
Aggregations