@@ -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" );
0 commit comments