Search in sources :

Example 6 with ProjectAggregate

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;
}
Also used : ProjectAggregate(io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate) ProjectId(io.spine.test.aggregate.ProjectId)

Example 7 with ProjectAggregate

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());
}
Also used : ProjectAggregate(io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate) ProjectId(io.spine.test.aggregate.ProjectId) Test(org.junit.Test)

Example 8 with ProjectAggregate

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());
}
Also used : ProjectAggregate(io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate) Test(org.junit.Test)

Example 9 with ProjectAggregate

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);
}
Also used : ProjectAggregate(io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate) ProjectId(io.spine.test.aggregate.ProjectId)

Example 10 with ProjectAggregate

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());
}
Also used : ProjectAggregate(io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate) ProjectId(io.spine.test.aggregate.ProjectId) Test(org.junit.Test)

Aggregations

ProjectAggregate (io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate)13 Test (org.junit.Test)11 ProjectId (io.spine.test.aggregate.ProjectId)7 Event (io.spine.core.Event)1 TestEventFactory (io.spine.server.command.TestEventFactory)1 TenantAwareOperation (io.spine.server.tenant.TenantAwareOperation)1 AggProjectArchived (io.spine.test.aggregate.event.AggProjectArchived)1