@@ -88,8 +88,7 @@ public void testCanRunCount() {
88
88
"b" , map ("k" , "b" ),
89
89
"c" , map ("k" , "c" )));
90
90
91
- AggregateQuerySnapshot snapshot =
92
- waitFor (collection .count ().get (AggregateSource .SERVER_DIRECT ));
91
+ AggregateQuerySnapshot snapshot = waitFor (collection .count ().get (AggregateSource .SERVER ));
93
92
assertEquals (Long .valueOf (3 ), snapshot .getCount ());
94
93
}
95
94
@@ -103,7 +102,7 @@ public void testCanRunCountWithFilters() {
103
102
"c" , map ("k" , "c" )));
104
103
105
104
AggregateQuerySnapshot snapshot =
106
- waitFor (collection .whereEqualTo ("k" , "b" ).count ().get (AggregateSource .SERVER_DIRECT ));
105
+ waitFor (collection .whereEqualTo ("k" , "b" ).count ().get (AggregateSource .SERVER ));
107
106
assertEquals (Long .valueOf (1 ), snapshot .getCount ());
108
107
}
109
108
@@ -118,7 +117,7 @@ public void testCanRunCountWithOrderBy() {
118
117
"d" , map ("absent" , "d" )));
119
118
120
119
AggregateQuerySnapshot snapshot =
121
- waitFor (collection .orderBy ("k" ).count ().get (AggregateSource .SERVER_DIRECT ));
120
+ waitFor (collection .orderBy ("k" ).count ().get (AggregateSource .SERVER ));
122
121
// "d" is filtered out because it is ordered by "k".
123
122
assertEquals (Long .valueOf (3 ), snapshot .getCount ());
124
123
}
@@ -132,7 +131,7 @@ public void testTerminateDoesNotCrashWithFlyingCountQuery() {
132
131
"b" , map ("k" , "b" ),
133
132
"c" , map ("k" , "c" )));
134
133
135
- collection .orderBy ("k" ).count ().get (AggregateSource .SERVER_DIRECT );
134
+ collection .orderBy ("k" ).count ().get (AggregateSource .SERVER );
136
135
waitFor (collection .firestore .terminate ());
137
136
}
138
137
@@ -146,15 +145,15 @@ public void testSnapshotEquals() {
146
145
"c" , map ("k" , "c" )));
147
146
148
147
AggregateQuerySnapshot snapshot1 =
149
- waitFor (collection .whereEqualTo ("k" , "b" ).count ().get (AggregateSource .SERVER_DIRECT ));
148
+ waitFor (collection .whereEqualTo ("k" , "b" ).count ().get (AggregateSource .SERVER ));
150
149
AggregateQuerySnapshot snapshot1_same =
151
- waitFor (collection .whereEqualTo ("k" , "b" ).count ().get (AggregateSource .SERVER_DIRECT ));
150
+ waitFor (collection .whereEqualTo ("k" , "b" ).count ().get (AggregateSource .SERVER ));
152
151
153
152
AggregateQuerySnapshot snapshot2 =
154
- waitFor (collection .whereEqualTo ("k" , "a" ).count ().get (AggregateSource .SERVER_DIRECT ));
153
+ waitFor (collection .whereEqualTo ("k" , "a" ).count ().get (AggregateSource .SERVER ));
155
154
waitFor (collection .document ("d" ).set (map ("k" , "a" )));
156
155
AggregateQuerySnapshot snapshot2_different =
157
- waitFor (collection .whereEqualTo ("k" , "a" ).count ().get (AggregateSource .SERVER_DIRECT ));
156
+ waitFor (collection .whereEqualTo ("k" , "a" ).count ().get (AggregateSource .SERVER ));
158
157
159
158
assertTrue (snapshot1 .equals (snapshot1_same ));
160
159
assertEquals (snapshot1 .hashCode (), snapshot1_same .hashCode ());
@@ -196,7 +195,7 @@ public void testCanRunCollectionGroupQuery() {
196
195
waitFor (batch .commit ());
197
196
198
197
AggregateQuerySnapshot snapshot =
199
- waitFor (db .collectionGroup (collectionGroup ).count ().get (AggregateSource .SERVER_DIRECT ));
198
+ waitFor (db .collectionGroup (collectionGroup ).count ().get (AggregateSource .SERVER ));
200
199
assertEquals (
201
200
Long .valueOf (5 ), // "cg-doc1", "cg-doc2", "cg-doc3", "cg-doc4", "cg-doc5",
202
201
snapshot .getCount ());
@@ -213,17 +212,12 @@ public void testCanRunCountWithFiltersAndLimits() {
213
212
"d" , map ("k" , "d" )));
214
213
215
214
AggregateQuerySnapshot snapshot =
216
- waitFor (
217
- collection .whereEqualTo ("k" , "a" ).limit (2 ).count ().get (AggregateSource .SERVER_DIRECT ));
215
+ waitFor (collection .whereEqualTo ("k" , "a" ).limit (2 ).count ().get (AggregateSource .SERVER ));
218
216
assertEquals (Long .valueOf (2 ), snapshot .getCount ());
219
217
220
218
snapshot =
221
219
waitFor (
222
- collection
223
- .whereEqualTo ("k" , "a" )
224
- .limitToLast (2 )
225
- .count ()
226
- .get (AggregateSource .SERVER_DIRECT ));
220
+ collection .whereEqualTo ("k" , "a" ).limitToLast (2 ).count ().get (AggregateSource .SERVER ));
227
221
assertEquals (Long .valueOf (2 ), snapshot .getCount ());
228
222
229
223
snapshot =
@@ -232,20 +226,18 @@ public void testCanRunCountWithFiltersAndLimits() {
232
226
.whereEqualTo ("k" , "d" )
233
227
.limitToLast (1000 )
234
228
.count ()
235
- .get (AggregateSource .SERVER_DIRECT ));
229
+ .get (AggregateSource .SERVER ));
236
230
assertEquals (Long .valueOf (1 ), snapshot .getCount ());
237
231
}
238
232
239
233
@ Test
240
234
public void testCanRunCountOnNonExistentCollection () {
241
235
CollectionReference collection = testFirestore ().collection ("random-coll" );
242
236
243
- AggregateQuerySnapshot snapshot =
244
- waitFor (collection .count ().get (AggregateSource .SERVER_DIRECT ));
237
+ AggregateQuerySnapshot snapshot = waitFor (collection .count ().get (AggregateSource .SERVER ));
245
238
assertEquals (Long .valueOf (0 ), snapshot .getCount ());
246
239
247
- snapshot =
248
- waitFor (collection .whereEqualTo ("k" , 100 ).count ().get (AggregateSource .SERVER_DIRECT ));
240
+ snapshot = waitFor (collection .whereEqualTo ("k" , 100 ).count ().get (AggregateSource .SERVER ));
249
241
assertEquals (Long .valueOf (0 ), snapshot .getCount ());
250
242
}
251
243
@@ -259,14 +251,13 @@ public void testFailWithoutNetwork() {
259
251
"c" , map ("k" , "c" )));
260
252
waitFor (collection .getFirestore ().disableNetwork ());
261
253
262
- Exception e = waitForException (collection .count ().get (AggregateSource .SERVER_DIRECT ));
254
+ Exception e = waitForException (collection .count ().get (AggregateSource .SERVER ));
263
255
assertThat (e , instanceOf (FirebaseFirestoreException .class ));
264
256
assertEquals (
265
257
FirebaseFirestoreException .Code .UNAVAILABLE , ((FirebaseFirestoreException ) e ).getCode ());
266
258
267
259
waitFor (collection .getFirestore ().enableNetwork ());
268
- AggregateQuerySnapshot snapshot =
269
- waitFor (collection .count ().get (AggregateSource .SERVER_DIRECT ));
260
+ AggregateQuerySnapshot snapshot = waitFor (collection .count ().get (AggregateSource .SERVER ));
270
261
assertEquals (Long .valueOf (3 ), snapshot .getCount ());
271
262
}
272
263
}
0 commit comments