Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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