Skip to content

Commit 23e109f

Browse files
committed
resolve comments
1 parent 624afc9 commit 23e109f

File tree

1 file changed

+10
-10
lines changed
  • firebase-firestore/src/androidTest/java/com/google/firebase/firestore

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import com.google.firebase.firestore.testutil.EventAccumulator;
4040
import com.google.firebase.firestore.testutil.IntegrationTestUtil;
4141
import java.util.ArrayList;
42+
import java.util.HashMap;
4243
import java.util.LinkedHashMap;
4344
import java.util.List;
4445
import java.util.Map;
@@ -1032,40 +1033,39 @@ public void testMultipleUpdatesWhileOffline() {
10321033
}
10331034

10341035
@Test
1035-
public void resumingQueryShouldRemoveDeletedDocumentsIndicatedByExistenceFilter() {
1036-
Map<String, Map<String, Object>> testDocs = new LinkedHashMap<>();
1036+
public void resumingQueryShouldRemoveDeletedDocumentsIndicatedByExistenceFilter()
1037+
throws InterruptedException {
1038+
Map<String, Map<String, Object>> testData = new HashMap<>();
10371039
for (int i = 1; i <= 100; i++) {
1038-
testDocs.put("doc" + i, map("key", i));
1040+
testData.put("doc" + i, map("key", i));
10391041
}
10401042

10411043
// Setup firestore with disabled persistence and populate a collection with testDocs.
10421044
FirebaseFirestore firestore = testFirestore();
10431045
firestore.setFirestoreSettings(
10441046
new FirebaseFirestoreSettings.Builder().setPersistenceEnabled(false).build());
10451047
CollectionReference collection = firestore.collection(autoId());
1046-
writeAllDocs(collection, testDocs);
1048+
writeAllDocs(collection, testData);
10471049

1050+
// Populate the cache and save the resume token.
10481051
QuerySnapshot snapshot1 = waitFor(collection.get());
10491052
assertEquals(snapshot1.size(), 100);
1053+
List<DocumentSnapshot> documents = snapshot1.getDocuments();
10501054

10511055
// Delete 50 docs in transaction so that it doesn't affect local cache.
10521056
waitFor(
10531057
firestore.runTransaction(
10541058
transaction -> {
10551059
for (int i = 1; i <= 50; i++) {
1056-
DocumentReference docRef = collection.document("doc" + i);
1060+
DocumentReference docRef = documents.get(i).getReference();
10571061
transaction.delete(docRef);
10581062
}
10591063
return null;
10601064
}));
10611065

10621066
// Wait 10 seconds, during which Watch will stop tracking the query
10631067
// and will send an existence filter rather than "delete" events.
1064-
try {
1065-
Thread.sleep(10000);
1066-
} catch (InterruptedException ex) {
1067-
Thread.currentThread().interrupt();
1068-
}
1068+
Thread.sleep(10000);
10691069

10701070
QuerySnapshot snapshot2 = waitFor(collection.get());
10711071
assertEquals(snapshot2.size(), 50);

0 commit comments

Comments
 (0)