use of com.google.firebase.firestore.model.mutation.MutationBatch in project firebase-android-sdk by firebase.
the class LocalStoreTestCase method rejectMutation.
private void rejectMutation() {
MutationBatch batch = batches.get(0);
batches.remove(0);
lastChanges = localStore.rejectBatch(batch.getBatchId());
}
use of com.google.firebase.firestore.model.mutation.MutationBatch in project firebase-android-sdk by firebase.
the class LocalStoreTestCase method writeMutations.
private void writeMutations(List<Mutation> mutations) {
LocalDocumentsResult result = localStore.writeLocally(mutations);
batches.add(new MutationBatch(result.getBatchId(), Timestamp.now(), Collections.emptyList(), mutations));
lastChanges = result.getDocuments();
}
use of com.google.firebase.firestore.model.mutation.MutationBatch in project firebase-android-sdk by firebase.
the class LocalStoreTestCase method testMutationBatchKeys.
@Test
public void testMutationBatchKeys() {
SetMutation set1 = setMutation("foo/bar", map("foo", "bar"));
SetMutation set2 = setMutation("foo/baz", map("foo", "baz"));
MutationBatch batch = new MutationBatch(1, Timestamp.now(), Collections.emptyList(), asList(set1, set2));
Set<DocumentKey> keys = batch.getKeys();
assertEquals(2, keys.size());
}
use of com.google.firebase.firestore.model.mutation.MutationBatch in project firebase-android-sdk by firebase.
the class MutationQueueTestCase method testNextMutationBatchAfterBatchId.
@Test
public void testNextMutationBatchAfterBatchId() {
List<MutationBatch> batches = createBatches(10);
List<MutationBatch> removed = removeFirstBatches(3, batches);
for (int i = 0; i < batches.size() - 1; i++) {
MutationBatch current = batches.get(i);
MutationBatch next = batches.get(i + 1);
MutationBatch found = mutationQueue.getNextMutationBatchAfterBatchId(current.getBatchId());
assertNotNull(found);
assertEquals(next.getBatchId(), found.getBatchId());
}
for (int i = 0; i < removed.size(); i++) {
MutationBatch current = removed.get(i);
MutationBatch next = batches.get(0);
MutationBatch found = mutationQueue.getNextMutationBatchAfterBatchId(current.getBatchId());
assertNotNull(found);
assertEquals(next.getBatchId(), found.getBatchId());
}
MutationBatch first = batches.get(0);
MutationBatch found = mutationQueue.getNextMutationBatchAfterBatchId(first.getBatchId() - 42);
assertNotNull(found);
assertEquals(first.getBatchId(), found.getBatchId());
MutationBatch last = batches.get(batches.size() - 1);
MutationBatch notFound = mutationQueue.getNextMutationBatchAfterBatchId(last.getBatchId());
assertNull(notFound);
}
use of com.google.firebase.firestore.model.mutation.MutationBatch in project firebase-android-sdk by firebase.
the class MutationQueueTestCase method testAllMutationBatchesAffectingDocumentKeys.
@Test
public void testAllMutationBatchesAffectingDocumentKeys() {
List<Mutation> mutations = asList(setMutation("fob/bar", map("a", 1)), setMutation("foo/bar", map("a", 1)), patchMutation("foo/bar", map("b", 1)), setMutation("foo/bar/suffix/key", map("a", 1)), setMutation("foo/baz", map("a", 1)), setMutation("food/bar", map("a", 1)));
// Store all the mutations.
List<MutationBatch> batches = new ArrayList<>();
persistence.runTransaction("New mutation batch", () -> {
for (Mutation mutation : mutations) {
batches.add(mutationQueue.addMutationBatch(Timestamp.now(), Collections.emptyList(), asList(mutation)));
}
});
ImmutableSortedSet<DocumentKey> keys = DocumentKey.emptyKeySet().insert(key("foo/bar")).insert(key("foo/baz"));
List<MutationBatch> expected = asList(batches.get(1), batches.get(2), batches.get(4));
List<MutationBatch> matches = mutationQueue.getAllMutationBatchesAffectingDocumentKeys(keys);
assertEquals(expected, matches);
}
Aggregations