use of com.google.protobuf.FieldMask 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<I> ids = fillStorage(10).subList(0, 5);
final String projectDescriptor = Project.getDescriptor().getFullName();
final FieldMask fieldMask = maskForPaths(projectDescriptor + ".id", projectDescriptor + ".status");
final Iterable<EntityRecord> read = storage.readMultiple(ids, fieldMask);
assertSize(ids.size(), read);
// Check data consistency
for (EntityRecord record : read) {
final Project state = checkProjectIdIsInList(record, ids);
assertMatchesMask(state, fieldMask);
}
}
use of com.google.protobuf.FieldMask in project core-java by SpineEventEngine.
the class QueryFactoryShould method checkFieldMaskEmpty.
private static void checkFieldMaskEmpty(Query query) {
final FieldMask fieldMask = query.getFieldMask();
assertNotNull(fieldMask);
assertEquals(FieldMask.getDefaultInstance(), fieldMask);
}
use of com.google.protobuf.FieldMask in project core-java by SpineEventEngine.
the class QueryFactoryShould method verifySinglePathInQuery.
private static void verifySinglePathInQuery(String expectedEntityPath, Query query) {
final FieldMask fieldMask = query.getFieldMask();
// as we set the only path value.
assertEquals(1, fieldMask.getPathsCount());
final String firstPath = fieldMask.getPaths(0);
assertEquals(expectedEntityPath, firstPath);
}
use of com.google.protobuf.FieldMask in project core-java by SpineEventEngine.
the class QueryBuilderShould method create_queries_with_field_mask.
@Test
public void create_queries_with_field_mask() {
final String fieldName = "TestEntity.firstField";
final Query query = factory().query().select(TestEntity.class).withMask(fieldName).build();
assertNotNull(query);
assertTrue(query.hasFieldMask());
final FieldMask mask = query.getFieldMask();
final Collection<String> fieldNames = mask.getPathsList();
assertSize(1, fieldNames);
assertContains(fieldName, fieldNames);
}
use of com.google.protobuf.FieldMask in project core-java by SpineEventEngine.
the class ProjectionStorageShould method retrieve_empty_map_if_storage_is_empty.
// because the behaviour to test is different
@SuppressWarnings("MethodDoesntCallSuperMethod")
@Override
@Test
public void retrieve_empty_map_if_storage_is_empty() {
final Map<I, EntityRecord> noMaskEntiries = storage.readAll();
final FieldMask nonEmptyMask = FieldMask.newBuilder().addPaths("invalid_path").build();
final Map<I, EntityRecord> maskedEntries = storage.readAll(nonEmptyMask);
assertEmpty(noMaskEntiries);
assertEmpty(maskedEntries);
// Same type
assertEquals(noMaskEntiries, maskedEntries);
}
Aggregations