@@ -1068,21 +1068,18 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
1068
1068
}
1069
1069
assertWithMessage ("createdDocuments" ).that (createdDocuments ).hasSize (100 );
1070
1070
1071
- // Delete 50 of the 100 documents. Do this in a transaction , rather than
1072
- // DocumentReference.delete(), to avoid affecting the local cache.
1071
+ // Delete 50 of the 100 documents. Use a WriteBatch , rather than DocumentReference.delete(),
1072
+ // to avoid affecting the local cache.
1073
1073
HashSet <String > deletedDocumentIds = new HashSet <>();
1074
- waitFor (
1075
- collection
1076
- .getFirestore ()
1077
- .runTransaction (
1078
- transaction -> {
1079
- for (int i = 0 ; i < createdDocuments .size (); i += 2 ) {
1080
- DocumentReference documentToDelete = createdDocuments .get (i );
1081
- transaction .delete (documentToDelete );
1082
- deletedDocumentIds .add (documentToDelete .getId ());
1083
- }
1084
- return null ;
1085
- }));
1074
+ {
1075
+ WriteBatch writeBatchForDocumentDeletes = collection .getFirestore ().batch ();
1076
+ for (int i = 0 ; i < createdDocuments .size (); i += 2 ) {
1077
+ DocumentReference documentToDelete = createdDocuments .get (i );
1078
+ writeBatchForDocumentDeletes .delete (documentToDelete );
1079
+ deletedDocumentIds .add (documentToDelete .getId ());
1080
+ }
1081
+ waitFor (writeBatchForDocumentDeletes .commit ());
1082
+ }
1086
1083
assertWithMessage ("deletedDocumentIds" ).that (deletedDocumentIds ).hasSize (50 );
1087
1084
1088
1085
// Wait for 10 seconds, during which Watch will stop tracking the query and will send an
@@ -1240,22 +1237,15 @@ public void bloomFilterShouldCorrectlyEncodeComplexUnicodeCharacters() throws Ex
1240
1237
.containsExactlyElementsIn (testDocIds );
1241
1238
}
1242
1239
1243
- // Delete one of the documents so that the next call to getDocs () will experience an existence
1244
- // filter mismatch. Do this deletion in a transaction , rather than using deleteDoc (), to avoid
1240
+ // Delete one of the documents so that the next call to collection.get () will experience an
1241
+ // existence filter mismatch. Use a WriteBatch , rather than DocumentReference.delete (), to avoid
1245
1242
// affecting the local cache.
1246
1243
DocumentReference documentToDelete = collection .document ("DocumentToDelete" );
1247
- waitFor (
1248
- collection
1249
- .getFirestore ()
1250
- .runTransaction (
1251
- transaction -> {
1252
- DocumentSnapshot documentToDeleteSnapshot = transaction .get (documentToDelete );
1253
- assertWithMessage ("documentToDeleteSnapshot.exists()" )
1254
- .that (documentToDeleteSnapshot .exists ())
1255
- .isTrue ();
1256
- transaction .delete (documentToDelete );
1257
- return null ;
1258
- }));
1244
+ {
1245
+ WriteBatch writeBatchForDocumentDeletes = collection .getFirestore ().batch ();
1246
+ writeBatchForDocumentDeletes .delete (documentToDelete );
1247
+ waitFor (writeBatchForDocumentDeletes .commit ());
1248
+ }
1259
1249
1260
1250
// Wait for 10 seconds, during which Watch will stop tracking the query and will send an
1261
1251
// existence filter rather than "delete" events when the query is resumed.
0 commit comments