use of com.google.cloud.spring.data.datastore.core.mapping.event.AfterQueryEvent in project spring-cloud-gcp by GoogleCloudPlatform.
the class DatastoreTemplateTests method queryByExampleSimpleEntityTest.
@Test
void queryByExampleSimpleEntityTest() {
EntityQuery.Builder builder = Query.newEntityQueryBuilder().setKind("test_kind");
StructuredQuery.CompositeFilter filter = StructuredQuery.CompositeFilter.and(PropertyFilter.eq("color", "simple_test_color"), PropertyFilter.eq("int_field", 1));
EntityQuery query = builder.setFilter(filter).build();
verifyBeforeAndAfterEvents(null, new AfterQueryEvent(Collections.emptyList(), query), () -> this.datastoreTemplate.queryByExample(Example.of(this.simpleTestEntity, ExampleMatcher.matching().withIgnorePaths("id")), null), x -> x.verify(this.datastore, times(1)).run(query));
}
use of com.google.cloud.spring.data.datastore.core.mapping.event.AfterQueryEvent in project spring-cloud-gcp by GoogleCloudPlatform.
the class DatastoreTemplate method queryIterable.
@Override
public <A, T> DatastoreResultsIterable<T> queryIterable(Query<A> query, Function<A, T> entityFunc) {
QueryResults<A> results = getDatastoreReadWriter().run(query);
List resultsList = new ArrayList();
// cursor is not populated until we iterate
results.forEachRemaining(e -> resultsList.add(entityFunc.apply(e)));
DatastoreResultsIterable<T> resultsIterable = new DatastoreResultsIterable<>(resultsList, results.getCursorAfter());
maybeEmitEvent(new AfterQueryEvent(resultsIterable, query));
return resultsIterable;
}
Aggregations