use of com.google.firebase.firestore.model.DocumentKey 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);
}
use of com.google.firebase.firestore.model.DocumentKey in project firebase-android-sdk by firebase.
the class RemoteDocumentCacheTestCase method testGetAllFromSinceReadTimeAndNanoseconds.
@Test
public void testGetAllFromSinceReadTimeAndNanoseconds() {
add(doc("b/old", 1, DOC_DATA), version(1, 1));
add(doc("b/current", 1, DOC_DATA), version(1, 2));
add(doc("b/new", 1, DOC_DATA), version(1, 3));
ResourcePath collection = path("b");
Map<DocumentKey, MutableDocument> results = remoteDocumentCache.getAll(collection, IndexOffset.createSuccessor(version(1, 2), -1));
assertThat(results.values()).containsExactly(doc("b/new", 1, DOC_DATA));
}
use of com.google.firebase.firestore.model.DocumentKey in project firebase-android-sdk by firebase.
the class RemoteDocumentCacheTestCase method testGetAllFromExcludesSubcollections.
@Test
public void testGetAllFromExcludesSubcollections() {
addTestDocumentAtPath("a/1");
addTestDocumentAtPath("a/1/b/1");
addTestDocumentAtPath("a/2");
ResourcePath collection = path("a");
Map<DocumentKey, MutableDocument> results = remoteDocumentCache.getAll(collection, IndexOffset.NONE);
assertThat(results.values()).containsExactly(doc("a/1", 42, DOC_DATA), doc("a/2", 42, DOC_DATA));
}
use of com.google.firebase.firestore.model.DocumentKey in project firebase-android-sdk by firebase.
the class RemoteDocumentCacheTestCase method testGetAllFromSinceReadTimeAndDocumentKey.
@Test
public void testGetAllFromSinceReadTimeAndDocumentKey() {
addTestDocumentAtPath("b/a", /* updateTime= */
1, /* readTime= */
11);
addTestDocumentAtPath("b/b", /* updateTime= */
2, /* readTime= = */
11);
addTestDocumentAtPath("b/c", /* updateTime= */
3, /* readTime= = */
11);
addTestDocumentAtPath("b/d", /* updateTime= */
4, /* readTime= = */
12);
ResourcePath collection = path("b");
Map<DocumentKey, MutableDocument> results = remoteDocumentCache.getAll(collection, IndexOffset.create(version(11), key("b/b"), -1));
assertThat(results.values()).containsExactly(doc("b/c", 3, DOC_DATA), doc("b/d", 4, DOC_DATA));
}
use of com.google.firebase.firestore.model.DocumentKey in project firebase-android-sdk by firebase.
the class RemoteDocumentCacheTestCase method testGetAllFromCollection.
@Test
public void testGetAllFromCollection() {
addTestDocumentAtPath("a/1");
addTestDocumentAtPath("b/1");
addTestDocumentAtPath("b/2");
addTestDocumentAtPath("c/1");
ResourcePath collection = path("b");
Map<DocumentKey, MutableDocument> results = remoteDocumentCache.getAll(collection, IndexOffset.NONE);
assertThat(results.values()).containsExactly(doc("b/1", 42, DOC_DATA), doc("b/2", 42, DOC_DATA));
}
Aggregations