@@ -88,9 +88,8 @@ 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 ));
93
- assertEquals (Long .valueOf (3 ), snapshot .getCount ());
91
+ AggregateQuerySnapshot snapshot = waitFor (collection .count ().get (AggregateSource .SERVER ));
92
+ assertEquals (3L , snapshot .getCount ());
94
93
}
95
94
96
95
@ Test
@@ -103,8 +102,8 @@ 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 ));
107
- assertEquals (Long . valueOf ( 1 ) , snapshot .getCount ());
105
+ waitFor (collection .whereEqualTo ("k" , "b" ).count ().get (AggregateSource .SERVER ));
106
+ assertEquals (1L , snapshot .getCount ());
108
107
}
109
108
110
109
@ Test
@@ -118,9 +117,9 @@ 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
- assertEquals (Long . valueOf ( 3 ) , snapshot .getCount ());
122
+ assertEquals (3L , snapshot .getCount ());
124
123
}
125
124
126
125
@ Test
@@ -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,9 +195,9 @@ 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
- Long . valueOf ( 5 ) , // "cg-doc1", "cg-doc2", "cg-doc3", "cg-doc4", "cg-doc5",
200
+ 5L , // "cg-doc1", "cg-doc2", "cg-doc3", "cg-doc4", "cg-doc5",
202
201
snapshot .getCount ());
203
202
}
204
203
@@ -213,40 +212,33 @@ 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 ));
218
- assertEquals (Long .valueOf (2 ), snapshot .getCount ());
215
+ waitFor (collection .whereEqualTo ("k" , "a" ).limit (2 ).count ().get (AggregateSource .SERVER ));
216
+ assertEquals (2L , 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 ));
227
- assertEquals (Long .valueOf (2 ), snapshot .getCount ());
220
+ collection .whereEqualTo ("k" , "a" ).limitToLast (2 ).count ().get (AggregateSource .SERVER ));
221
+ assertEquals (2L , snapshot .getCount ());
228
222
229
223
snapshot =
230
224
waitFor (
231
225
collection
232
226
.whereEqualTo ("k" , "d" )
233
227
.limitToLast (1000 )
234
228
.count ()
235
- .get (AggregateSource .SERVER_DIRECT ));
236
- assertEquals (Long . valueOf ( 1 ) , snapshot .getCount ());
229
+ .get (AggregateSource .SERVER ));
230
+ assertEquals (1L , 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 ));
245
- assertEquals (Long .valueOf (0 ), snapshot .getCount ());
237
+ AggregateQuerySnapshot snapshot = waitFor (collection .count ().get (AggregateSource .SERVER ));
238
+ assertEquals (0L , snapshot .getCount ());
246
239
247
- snapshot =
248
- waitFor (collection .whereEqualTo ("k" , 100 ).count ().get (AggregateSource .SERVER_DIRECT ));
249
- assertEquals (Long .valueOf (0 ), snapshot .getCount ());
240
+ snapshot = waitFor (collection .whereEqualTo ("k" , 100 ).count ().get (AggregateSource .SERVER ));
241
+ assertEquals (0L , snapshot .getCount ());
250
242
}
251
243
252
244
@ Test
@@ -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 ));
270
- assertEquals (Long .valueOf (3 ), snapshot .getCount ());
260
+ AggregateQuerySnapshot snapshot = waitFor (collection .count ().get (AggregateSource .SERVER ));
261
+ assertEquals (3L , snapshot .getCount ());
271
262
}
272
263
}
0 commit comments