use of io.spine.test.storage.ProjectId in project core-java by SpineEventEngine.
the class ProjectionStorageShould method fillStorage.
// Converter nullability issues
@SuppressWarnings("ConstantConditions")
private List<ProjectId> fillStorage(int count) {
final List<ProjectId> ids = new LinkedList<>();
for (int i = 0; i < count; i++) {
final ProjectId id = newId();
final Project state = Given.project(id, format("project-%d", i));
final Any packedState = AnyPacker.pack(state);
final EntityRecord rawRecord = EntityRecord.newBuilder().setState(packedState).setVersion(GivenVersion.withNumber(1)).build();
final EntityRecordWithColumns record = withLifecycleColumns(rawRecord);
storage.write(id, record);
ids.add(id);
}
return ids;
}
use of io.spine.test.storage.ProjectId in project core-java by SpineEventEngine.
the class ProjectionStorageShould method read_all_messages_with_field_mask.
@SuppressWarnings("MethodWithMultipleLoops")
@Test
public void read_all_messages_with_field_mask() {
final List<ProjectId> ids = fillStorage(5);
final String projectDescriptor = Project.getDescriptor().getFullName();
@SuppressWarnings("DuplicateStringLiteralInspection") final FieldMask // clashes with non-related tests.
fieldMask = maskForPaths(projectDescriptor + ".id", projectDescriptor + ".name");
final Iterator<EntityRecord> read = storage.readAll(fieldMask);
final Collection<EntityRecord> readRecords = newArrayList(read);
assertSize(ids.size(), readRecords);
for (EntityRecord record : readRecords) {
final Any packedState = record.getState();
final Project state = AnyPacker.unpack(packedState);
assertMatchesMask(state, fieldMask);
}
}
use of io.spine.test.storage.ProjectId in project core-java by SpineEventEngine.
the class StandStorageShould method checkIds.
protected void checkIds(List<AggregateStateId> ids, Iterator<EntityRecord> records) {
final Collection<EntityRecord> recordsToCheck = newArrayList(records);
assertSize(ids.size(), recordsToCheck);
final Collection<ProjectId> projectIds = Collections2.transform(ids, new Function<AggregateStateId, ProjectId>() {
@Nullable
@Override
public ProjectId apply(@Nullable AggregateStateId input) {
if (input == null) {
return null;
}
return (ProjectId) input.getAggregateId();
}
});
for (EntityRecord record : recordsToCheck) {
final Any packedState = record.getState();
final Project state = AnyPacker.unpack(packedState);
final ProjectId id = state.getId();
assertContains(id, projectIds);
}
}
Aggregations