Skip to content

Commit 2884055

Browse files
committed
AggregateSource.java: Rename SERVER_DIRECT to just SERVER
1 parent ed10eb5 commit 2884055

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

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

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ public void testCanRunCount() {
8888
"b", map("k", "b"),
8989
"c", map("k", "c")));
9090

91-
AggregateQuerySnapshot snapshot =
92-
waitFor(collection.count().get(AggregateSource.SERVER_DIRECT));
91+
AggregateQuerySnapshot snapshot = waitFor(collection.count().get(AggregateSource.SERVER));
9392
assertEquals(Long.valueOf(3), snapshot.getCount());
9493
}
9594

@@ -103,7 +102,7 @@ public void testCanRunCountWithFilters() {
103102
"c", map("k", "c")));
104103

105104
AggregateQuerySnapshot snapshot =
106-
waitFor(collection.whereEqualTo("k", "b").count().get(AggregateSource.SERVER_DIRECT));
105+
waitFor(collection.whereEqualTo("k", "b").count().get(AggregateSource.SERVER));
107106
assertEquals(Long.valueOf(1), snapshot.getCount());
108107
}
109108

@@ -118,7 +117,7 @@ public void testCanRunCountWithOrderBy() {
118117
"d", map("absent", "d")));
119118

120119
AggregateQuerySnapshot snapshot =
121-
waitFor(collection.orderBy("k").count().get(AggregateSource.SERVER_DIRECT));
120+
waitFor(collection.orderBy("k").count().get(AggregateSource.SERVER));
122121
// "d" is filtered out because it is ordered by "k".
123122
assertEquals(Long.valueOf(3), snapshot.getCount());
124123
}
@@ -132,7 +131,7 @@ public void testTerminateDoesNotCrashWithFlyingCountQuery() {
132131
"b", map("k", "b"),
133132
"c", map("k", "c")));
134133

135-
collection.orderBy("k").count().get(AggregateSource.SERVER_DIRECT);
134+
collection.orderBy("k").count().get(AggregateSource.SERVER);
136135
waitFor(collection.firestore.terminate());
137136
}
138137

@@ -146,15 +145,15 @@ public void testSnapshotEquals() {
146145
"c", map("k", "c")));
147146

148147
AggregateQuerySnapshot snapshot1 =
149-
waitFor(collection.whereEqualTo("k", "b").count().get(AggregateSource.SERVER_DIRECT));
148+
waitFor(collection.whereEqualTo("k", "b").count().get(AggregateSource.SERVER));
150149
AggregateQuerySnapshot snapshot1_same =
151-
waitFor(collection.whereEqualTo("k", "b").count().get(AggregateSource.SERVER_DIRECT));
150+
waitFor(collection.whereEqualTo("k", "b").count().get(AggregateSource.SERVER));
152151

153152
AggregateQuerySnapshot snapshot2 =
154-
waitFor(collection.whereEqualTo("k", "a").count().get(AggregateSource.SERVER_DIRECT));
153+
waitFor(collection.whereEqualTo("k", "a").count().get(AggregateSource.SERVER));
155154
waitFor(collection.document("d").set(map("k", "a")));
156155
AggregateQuerySnapshot snapshot2_different =
157-
waitFor(collection.whereEqualTo("k", "a").count().get(AggregateSource.SERVER_DIRECT));
156+
waitFor(collection.whereEqualTo("k", "a").count().get(AggregateSource.SERVER));
158157

159158
assertTrue(snapshot1.equals(snapshot1_same));
160159
assertEquals(snapshot1.hashCode(), snapshot1_same.hashCode());
@@ -196,7 +195,7 @@ public void testCanRunCollectionGroupQuery() {
196195
waitFor(batch.commit());
197196

198197
AggregateQuerySnapshot snapshot =
199-
waitFor(db.collectionGroup(collectionGroup).count().get(AggregateSource.SERVER_DIRECT));
198+
waitFor(db.collectionGroup(collectionGroup).count().get(AggregateSource.SERVER));
200199
assertEquals(
201200
Long.valueOf(5), // "cg-doc1", "cg-doc2", "cg-doc3", "cg-doc4", "cg-doc5",
202201
snapshot.getCount());
@@ -213,17 +212,12 @@ public void testCanRunCountWithFiltersAndLimits() {
213212
"d", map("k", "d")));
214213

215214
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));
218216
assertEquals(Long.valueOf(2), snapshot.getCount());
219217

220218
snapshot =
221219
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));
227221
assertEquals(Long.valueOf(2), snapshot.getCount());
228222

229223
snapshot =
@@ -232,20 +226,18 @@ public void testCanRunCountWithFiltersAndLimits() {
232226
.whereEqualTo("k", "d")
233227
.limitToLast(1000)
234228
.count()
235-
.get(AggregateSource.SERVER_DIRECT));
229+
.get(AggregateSource.SERVER));
236230
assertEquals(Long.valueOf(1), snapshot.getCount());
237231
}
238232

239233
@Test
240234
public void testCanRunCountOnNonExistentCollection() {
241235
CollectionReference collection = testFirestore().collection("random-coll");
242236

243-
AggregateQuerySnapshot snapshot =
244-
waitFor(collection.count().get(AggregateSource.SERVER_DIRECT));
237+
AggregateQuerySnapshot snapshot = waitFor(collection.count().get(AggregateSource.SERVER));
245238
assertEquals(Long.valueOf(0), snapshot.getCount());
246239

247-
snapshot =
248-
waitFor(collection.whereEqualTo("k", 100).count().get(AggregateSource.SERVER_DIRECT));
240+
snapshot = waitFor(collection.whereEqualTo("k", 100).count().get(AggregateSource.SERVER));
249241
assertEquals(Long.valueOf(0), snapshot.getCount());
250242
}
251243

@@ -259,14 +251,13 @@ public void testFailWithoutNetwork() {
259251
"c", map("k", "c")));
260252
waitFor(collection.getFirestore().disableNetwork());
261253

262-
Exception e = waitForException(collection.count().get(AggregateSource.SERVER_DIRECT));
254+
Exception e = waitForException(collection.count().get(AggregateSource.SERVER));
263255
assertThat(e, instanceOf(FirebaseFirestoreException.class));
264256
assertEquals(
265257
FirebaseFirestoreException.Code.UNAVAILABLE, ((FirebaseFirestoreException) e).getCode());
266258

267259
waitFor(collection.getFirestore().enableNetwork());
268-
AggregateQuerySnapshot snapshot =
269-
waitFor(collection.count().get(AggregateSource.SERVER_DIRECT));
260+
AggregateQuerySnapshot snapshot = waitFor(collection.count().get(AggregateSource.SERVER));
270261
assertEquals(Long.valueOf(3), snapshot.getCount());
271262
}
272263
}

firebase-firestore/src/main/java/com/google/firebase/firestore/AggregateSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ enum AggregateSource {
2222
*
2323
* <p>Requires client to be online.
2424
*/
25-
SERVER_DIRECT,
25+
SERVER,
2626
}

0 commit comments

Comments
 (0)