Skip to content

Commit 495020b

Browse files
committed
Change tests
1 parent 23b0229 commit 495020b

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/AggregationTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,11 @@ public void testThrowsAnErrorWhenGettingTheResultOfAnUnrequestedAggregation() {
575575
CollectionReference collection = testCollectionWithDocs(testDocs1);
576576

577577
AggregateQuerySnapshot snapshot =
578-
waitFor(collection.aggregate(sum("pages")).get(AggregateSource.SERVER));
578+
waitFor(
579+
collection
580+
.whereGreaterThan("pages", 200)
581+
.aggregate(sum("pages"))
582+
.get(AggregateSource.SERVER));
579583

580584
Exception exception = null;
581585
try {
@@ -860,25 +864,21 @@ public void testPerformsSumThatIsValidButCouldOverflowDuringAggregation() {
860864
"Skip this test if running against production because sum/avg is only support "
861865
+ "in emulator currently.",
862866
isRunningAgainstEmulator());
863-
867+
// Sum of rating would be 0, but if the accumulation overflow, we expect infinity
864868
Map<String, Map<String, Object>> testDocs =
865869
map(
866870
"a", map("author", "authorA", "title", "titleA", "rating", Double.MAX_VALUE),
867871
"b", map("author", "authorB", "title", "titleB", "rating", Double.MAX_VALUE),
868872
"c", map("author", "authorC", "title", "titleC", "rating", -Double.MAX_VALUE),
869-
"d", map("author", "authorD", "title", "titleD", "rating", -Double.MAX_VALUE),
870-
"e", map("author", "authorE", "title", "titleE", "rating", Double.MAX_VALUE),
871-
"f", map("author", "authorF", "title", "titleF", "rating", -Double.MAX_VALUE),
872-
"g", map("author", "authorG", "title", "titleG", "rating", -Double.MAX_VALUE),
873-
"h", map("author", "authorH", "title", "titleH", "rating", Double.MAX_VALUE));
873+
"d", map("author", "authorD", "title", "titleD", "rating", -Double.MAX_VALUE));
874874
CollectionReference collection = testCollectionWithDocs(testDocs);
875875

876876
AggregateQuerySnapshot snapshot =
877877
waitFor(collection.aggregate(sum("rating")).get(AggregateSource.SERVER));
878878

879879
Object sum = snapshot.get(sum("rating"));
880880
assertTrue(sum instanceof Long);
881-
assertEquals(sum, 0L);
881+
assertTrue(sum.equals(0L) || sum.equals(Long.MAX_VALUE) || sum.equals(Long.MIN_VALUE));
882882
}
883883

884884
@Test
@@ -1240,7 +1240,6 @@ public void allowsAliasesLongerThan1500Bytes() {
12401240
// 1500 bytes, the alias will be longer than 1500, which is the limit for aliases. This is to
12411241
// make sure the client
12421242
// can handle this corner case correctly.
1243-
12441243
StringBuilder builder = new StringBuilder(1500);
12451244
for (int i = 0; i < 1500; i++) {
12461245
builder.append("a");

firebase-firestore/src/main/java/com/google/firebase/firestore/core/Query.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,8 @@ private boolean matchesFilters(Document doc) {
403403

404404
/** A document must have a value for every ordering clause in order to show up in the results. */
405405
private boolean matchesOrderBy(Document doc) {
406-
// We must use `getNormalizedOrderBy()` to get the list of all orderBys (both implicit and explicit).
406+
// We must use `getNormalizedOrderBy()` to get the list of all orderBys (both implicit and
407+
// explicit).
407408
// Note that for OR queries, orderBy applies to all disjunction terms and implicit orderBys must
408409
// be taken into account. For example, the query "a > 1 || b==1" has an implicit "orderBy a" due
409410
// to the inequality, and is evaluated as "a > 1 orderBy a || b==1 orderBy a".

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/Datastore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public void onClose(Status status) {
225225
public Task<Map<String, Value>> runAggregateQuery(
226226
Query query, List<AggregateField> aggregateFields) {
227227
com.google.firestore.v1.Target.QueryTarget encodedQueryTarget =
228-
serializer.encodeQueryTarget(query.toTarget());
228+
serializer.encodeQueryTarget(query.toAggregateTarget());
229229
HashMap<String, String> aliasMap = new HashMap<>();
230230
StructuredAggregationQuery structuredAggregationQuery =
231231
serializer.encodeStructuredAggregationQuery(encodedQueryTarget, aggregateFields, aliasMap);

0 commit comments

Comments
 (0)