use of io.spine.test.aggregate.Project in project core-java by SpineEventEngine.
the class AggregateShould method transform_current_state_to_snapshot_event.
@Test
public void transform_current_state_to_snapshot_event() {
dispatchCommand(aggregate, env(createProject));
final Snapshot snapshot = aggregate().toShapshot();
final Project state = unpack(snapshot.getState());
assertEquals(ID, state.getId());
assertEquals(Status.CREATED, state.getStatus());
}
use of io.spine.test.aggregate.Project 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);
}
use of io.spine.test.aggregate.Project in project core-java by SpineEventEngine.
the class SubscriptionRecordShould method fail_to_match_improper_target.
@Test
public void fail_to_match_improper_target() {
final ProjectId nonExistingId = ProjectId.newBuilder().setId("never-existed").build();
final SubscriptionRecord notMatchingRecord = new SubscriptionRecord(Given.subscription(), Given.target(nonExistingId), Given.TYPE);
final Project entityState = Project.getDefaultInstance();
final Any wrappedState = AnyPacker.pack(entityState);
final ProjectId redundantId = ProjectId.getDefaultInstance();
final boolean matchResult = notMatchingRecord.matches(Given.TYPE, redundantId, wrappedState);
assertFalse(matchResult);
}
use of io.spine.test.aggregate.Project in project core-java by SpineEventEngine.
the class FieldMasksShould method apply_only_non_empty_mask_to_collection.
@SuppressWarnings({ "ObjectEquality", "MethodWithMultipleLoops" })
@Test
public void apply_only_non_empty_mask_to_collection() {
final FieldMask emptyMask = Given.fieldMask();
final Collection<Project> original = new LinkedList<>();
final int count = 5;
for (int i = 0; i < count; i++) {
final Project project = Given.newProject(format("test-data--%s", i));
original.add(project);
}
final Collection<Project> processed = FieldMasks.applyMask(emptyMask, original, Given.TYPE);
assertSize(original.size(), processed);
// The argument is not returned
assertFalse(original == processed);
// A copy of the argument is returned (Collection type may differ)
final Iterator<Project> processedProjects = processed.iterator();
for (Project anOriginal : original) {
assertTrue(processedProjects.next().equals(anOriginal));
}
}
use of io.spine.test.aggregate.Project in project core-java by SpineEventEngine.
the class FieldMasksShould method apply_mask_to_message_collections.
@SuppressWarnings({ "MethodWithMultipleLoops", "ObjectEquality" })
@Test
public void apply_mask_to_message_collections() {
final FieldMask fieldMask = Given.fieldMask(Project.STATUS_FIELD_NUMBER, Project.TASK_FIELD_NUMBER);
final int count = 5;
final Collection<Project> original = new LinkedList<>();
for (int i = 0; i < count; i++) {
final Project project = Given.newProject(format("project-%s", i));
original.add(project);
}
final Collection<Project> masked = FieldMasks.applyMask(fieldMask, original, Given.TYPE);
assertSize(original.size(), masked);
// Collection references are not the same
assertFalse(original == masked);
for (Project project : masked) {
assertMatchesMask(project, fieldMask);
// Can't check repeated fields with assertMatchesMask
assertFalse(project.getTaskList().isEmpty());
}
}
Aggregations