use of io.spine.server.aggregate.given.aggregate.TestAggregate in project core-java by SpineEventEngine.
the class AggregateShould method traverse_the_history_iterating_through_newest_events_first.
@Test
public void traverse_the_history_iterating_through_newest_events_first() {
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(addTaskCommand, noOpObserver);
commandBus.post(newArrayList(addTaskCommand2, startCommand), noOpObserver);
final TestAggregate aggregate = repository.loadAggregate(tenantId, ID);
final Iterator<Event> history = aggregate.historyBackward();
assertEquals(startCommand.getId(), getRootCommandId(history.next()));
assertEquals(addTaskCommand2.getId(), getRootCommandId(history.next()));
assertEquals(addTaskCommand.getId(), getRootCommandId(history.next()));
assertEquals(createCommand.getId(), getRootCommandId(history.next()));
assertFalse(history.hasNext());
}
use of io.spine.server.aggregate.given.aggregate.TestAggregate in project core-java by SpineEventEngine.
the class AggregateShould method return_non_null_time_when_was_last_modified.
@Test
public void return_non_null_time_when_was_last_modified() {
final Timestamp creationTime = new TestAggregate(ID).whenModified();
assertNotNull(creationTime);
}
use of io.spine.server.aggregate.given.aggregate.TestAggregate 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.server.aggregate.given.aggregate.TestAggregate in project core-java by SpineEventEngine.
the class AggregateShould method newAggregate.
private static TestAggregate newAggregate(ProjectId id) {
final TestAggregate result = new TestAggregate(id);
result.init();
return result;
}
Aggregations