use of io.spine.test.storage.ProjectId in project core-java by SpineEventEngine.
the class StandStorageShould method checkIds.
protected void checkIds(List<AggregateStateId> ids, Collection<EntityRecord> records) {
assertSize(ids.size(), records);
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 : records) {
final Any packedState = record.getState();
final Project state = AnyPacker.unpack(packedState);
final ProjectId id = state.getId();
assertContains(id, projectIds);
}
}
use of io.spine.test.storage.ProjectId in project core-java by SpineEventEngine.
the class ProjectionStorageShould method read_all_messages.
@SuppressWarnings("MethodWithMultipleLoops")
@Test
public void read_all_messages() {
final List<ProjectId> ids = fillStorage(5);
final Iterator<EntityRecord> read = storage.readAll();
final Collection<EntityRecord> readRecords = newArrayList(read);
assertSize(ids.size(), readRecords);
for (EntityRecord record : readRecords) {
final Project state = AnyPacker.unpack(record.getState());
final ProjectId id = state.getId();
assertContains(id, ids);
}
}
use of io.spine.test.storage.ProjectId in project core-java by SpineEventEngine.
the class ProjectionStorageShould method perform_read_bulk_operations.
@SuppressWarnings({ "MethodWithMultipleLoops", "BreakStatement" })
@Test
public void perform_read_bulk_operations() {
// Get a subset of IDs
final List<ProjectId> ids = fillStorage(10).subList(0, 5);
final Iterator<EntityRecord> read = storage.readMultiple(ids);
final Collection<EntityRecord> readRecords = newArrayList(read);
assertSize(ids.size(), readRecords);
// Check data consistency
for (EntityRecord record : readRecords) {
checkProjectIdIsInList(record, ids);
}
}
use of io.spine.test.storage.ProjectId in project core-java by SpineEventEngine.
the class ProjectionStorageShould method checkProjectIdIsInList.
@SuppressWarnings("BreakStatement")
private static Project checkProjectIdIsInList(EntityRecord project, List<ProjectId> ids) {
final Any packedState = project.getState();
final Project state = AnyPacker.unpack(packedState);
final ProjectId id = state.getId();
boolean isIdPresent = false;
for (ProjectId genericId : ids) {
isIdPresent = genericId.equals(id);
if (isIdPresent) {
break;
}
}
assertTrue(isIdPresent);
return state;
}
use of io.spine.test.storage.ProjectId in project core-java by SpineEventEngine.
the class ProjectionStorageShould method perform_bulk_read_with_field_mask_operation.
@SuppressWarnings({ "MethodWithMultipleLoops", "BreakStatement" })
@Test
public void perform_bulk_read_with_field_mask_operation() {
// Get a subset of IDs
final List<ProjectId> ids = fillStorage(10).subList(0, 5);
final String projectDescriptor = Project.getDescriptor().getFullName();
final FieldMask fieldMask = maskForPaths(projectDescriptor + ".id", projectDescriptor + ".status");
final Iterator<EntityRecord> read = storage.readMultiple(ids, fieldMask);
final Collection<EntityRecord> readRecords = newArrayList(read);
assertSize(ids.size(), readRecords);
// Check data consistency
for (EntityRecord record : readRecords) {
final Project state = checkProjectIdIsInList(record, ids);
assertMatchesMask(state, fieldMask);
}
}
Aggregations