Search in sources :

Example 11 with ProjectId

use of io.spine.test.aggregate.ProjectId in project core-java by SpineEventEngine.

the class AggregateRepositoryShould method restore_aggregate_using_snapshot.

@Test
public void restore_aggregate_using_snapshot() {
    final ProjectId id = Sample.messageOfType(ProjectId.class);
    final ProjectAggregate expected = givenAggregateWithUncommittedEvents(id);
    repository.setSnapshotTrigger(expected.getUncommittedEvents().size());
    repository.store(expected);
    @SuppressWarnings("OptionalGetWithoutIsPresent") final ProjectAggregate actual = repository.find(id).get();
    assertEquals(expected.getId(), actual.getId());
    assertEquals(expected.getState(), actual.getState());
}
Also used : ProjectId(io.spine.test.aggregate.ProjectId) Test(org.junit.Test)

Example 12 with ProjectId

use of io.spine.test.aggregate.ProjectId in project core-java by SpineEventEngine.

the class AggregateRepositoryShould method call_get_aggregate_constructor_method_only_once.

@Test
public void call_get_aggregate_constructor_method_only_once() {
    final ProjectId id = Sample.messageOfType(ProjectId.class);
    repositorySpy.create(id);
    repositorySpy.create(id);
    verify(repositorySpy, times(1)).findEntityConstructor();
}
Also used : ProjectId(io.spine.test.aggregate.ProjectId) Test(org.junit.Test)

Example 13 with ProjectId

use of io.spine.test.aggregate.ProjectId in project core-java by SpineEventEngine.

the class AggregateRepositoryShould method createAndStoreAggregate.

private ProjectAggregate createAndStoreAggregate() {
    final ProjectId id = Sample.messageOfType(ProjectId.class);
    final ProjectAggregate aggregate = givenAggregateWithUncommittedEvents(id);
    repository.store(aggregate);
    return aggregate;
}
Also used : ProjectId(io.spine.test.aggregate.ProjectId)

Example 14 with ProjectId

use of io.spine.test.aggregate.ProjectId 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 = givenAggregateWithUncommittedEvents(id);
    repository.store(expected);
    @SuppressWarnings("OptionalGetWithoutIsPresent") final ProjectAggregate actual = repository.find(id).get();
    assertTrue(isNotDefault(actual.getState()));
    assertEquals(expected.getId(), actual.getId());
    assertEquals(expected.getState(), actual.getState());
}
Also used : ProjectId(io.spine.test.aggregate.ProjectId) Test(org.junit.Test)

Example 15 with ProjectId

use of io.spine.test.aggregate.ProjectId in project core-java by SpineEventEngine.

the class SubscriptionRecordShould method fail_to_match_improper_type.

@Test
public void fail_to_match_improper_type() {
    final SubscriptionRecord notMatchingRecord = new SubscriptionRecord(Given.subscription(), Given.target(), Given.TYPE);
    final Project entityState = Project.getDefaultInstance();
    final Any wrappedState = AnyPacker.pack(entityState);
    final ProjectId redundantId = ProjectId.getDefaultInstance();
    final boolean matchResult = notMatchingRecord.matches(Given.OTHER_TYPE, redundantId, wrappedState);
    assertFalse(matchResult);
}
Also used : Project(io.spine.test.aggregate.Project) ProjectId(io.spine.test.aggregate.ProjectId) Any(com.google.protobuf.Any) Test(org.junit.Test)

Aggregations

ProjectId (io.spine.test.aggregate.ProjectId)16 Test (org.junit.Test)12 Any (com.google.protobuf.Any)3 Project (io.spine.test.aggregate.Project)3 Message (com.google.protobuf.Message)2 Subscription (io.spine.client.Subscription)2 SubscriptionUpdate (io.spine.client.SubscriptionUpdate)2 Target (io.spine.client.Target)2 Topic (io.spine.client.Topic)2 AbstractVersionableEntity (io.spine.server.entity.AbstractVersionableEntity)2 VersionableEntity (io.spine.server.entity.VersionableEntity)2 Before (org.junit.Before)2 Response (io.spine.base.Response)1 CommandEnvelope (io.spine.envelope.CommandEnvelope)1 ProjectDefinition (io.spine.test.aggregate.ProjectDefinition)1 ImportEvents (io.spine.test.aggregate.command.ImportEvents)1