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());
}
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();
}
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;
}
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());
}
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);
}
Aggregations