use of io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate in project core-java by SpineEventEngine.
the class AggregateRepositoryShould method givenStoredAggregate.
/*
* Test environment methods that use internals of this test suite
* (and because of that are not moved to the test environment outside of this class).
**************************************************************************************/
private ProjectAggregate givenStoredAggregate() {
final ProjectId id = Sample.messageOfType(ProjectId.class);
final ProjectAggregate aggregate = GivenAggregate.withUncommittedEvents(id);
repository.store(aggregate);
return aggregate;
}
use of io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate in project core-java by SpineEventEngine.
the class AggregateRepositoryShould method store_and_load_aggregate.
@Test
public void store_and_load_aggregate() {
final ProjectId id = Sample.messageOfType(ProjectId.class);
final ProjectAggregate expected = GivenAggregate.withUncommittedEvents(id);
repository.store(expected);
final ProjectAggregate actual = repository.find(id).get();
assertTrue(isNotDefault(actual.getState()));
assertEquals(expected.getId(), actual.getId());
assertEquals(expected.getState(), actual.getState());
}
use of io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate in project core-java by SpineEventEngine.
the class AggregateRepositoryShould method find_deleted_aggregates.
@Test
public void find_deleted_aggregates() {
final ProjectAggregate aggregate = givenStoredAggregate();
final AggregateTransaction tx = AggregateTransaction.start(aggregate);
aggregate.setDeleted(true);
tx.commit();
repository.store(aggregate);
assertTrue(repository.find(aggregate.getId()).isPresent());
}
use of io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate in project core-java by SpineEventEngine.
the class AggregateRepositoryShould method givenStoredAggregateWithId.
private void givenStoredAggregateWithId(String id) {
final ProjectId projectId = givenAggregateId(id);
final ProjectAggregate aggregate = GivenAggregate.withUncommittedEvents(projectId);
repository.store(aggregate);
}
use of io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate in project core-java by SpineEventEngine.
the class AggregateRepositoryShould method pass_initial_snapshot_trigger_to_AggregateReadRequest.
@SuppressWarnings("unchecked")
@Test
public void pass_initial_snapshot_trigger_to_AggregateReadRequest() {
final AggregateRepository<ProjectId, ProjectAggregate> repositorySpy = spy(repository);
final AggregateStorage<ProjectId> storageSpy = spy(repositorySpy.aggregateStorage());
doReturn(storageSpy).when(repositorySpy).aggregateStorage();
final ProjectId id = Sample.messageOfType(ProjectId.class);
repositorySpy.loadOrCreate(id);
final ArgumentCaptor<AggregateReadRequest<ProjectId>> requestCaptor = ArgumentCaptor.forClass(AggregateReadRequest.class);
verify(storageSpy).read(requestCaptor.capture());
final AggregateReadRequest<ProjectId> passedRequest = requestCaptor.getValue();
assertEquals(id, passedRequest.getRecordId());
assertEquals(repositorySpy.getSnapshotTrigger(), passedRequest.getBatchSize());
}
Aggregations