Skip to content

Commit

Permalink
Merge pull request #178 from GoogleCloudPlatform/datastore
Browse files Browse the repository at this point in the history
Add region tags for projection query sample.
  • Loading branch information
tswast committed Apr 21, 2016
2 parents c462749 + 3c05bcf commit 771da44
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ public void projectionQuery_grouping_filtersDuplicates() {
putTestData("some duplicate", 0L);
putTestData("too big", 1L);

// [START grouping]
Query q = new Query("TestKind");
q.addProjection(new PropertyProjection("A", String.class));
q.addProjection(new PropertyProjection("B", Long.class));
q.setDistinct(true);
q.setFilter(Query.FilterOperator.LESS_THAN.of("B", 1L));
q.addSort("B", Query.SortDirection.DESCENDING);
q.addSort("A");
// [END grouping]

List<Entity> entities =
datastore.prepare(q).asList(FetchOptions.Builder.withLimit(5));
assertThat(entities).hasSize(1);
// [START_EXCLUDE silent]
Entity entity = entities.get(0);
assertThat((String) entity.getProperty("A")).named("entity.A").isEqualTo("some duplicate");
assertThat((long) entity.getProperty("B")).named("entity.B").isEqualTo(0L);
// [END_EXCLUDE]
}

private void putTestData(String a, long b) {
Expand Down

0 comments on commit 771da44

Please sign in to comment.