use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.
the class LocalStoreTestCase method testLoadingNamedQueriesAllocatesTargetsAndUpdatesTargetDocumentMapping.
@Test
public void testLoadingNamedQueriesAllocatesTargetsAndUpdatesTargetDocumentMapping() {
bundleDocuments(doc("foo1/bar", 1, map("sum", 1337)), doc("foo2/bar", 1, map("sum", 42)));
assertChanged(doc("foo1/bar", 1, map("sum", 1337)), doc("foo2/bar", 1, map("sum", 42)));
assertContains(doc("foo1/bar", 1, map("sum", 1337)));
assertContains(doc("foo2/bar", 1, map("sum", 42)));
Target target1 = Query.atPath(ResourcePath.fromString("foo1")).toTarget();
NamedQuery namedQuery1 = new NamedQuery("query-1", new BundledQuery(target1, Query.LimitType.LIMIT_TO_FIRST), new SnapshotVersion(Timestamp.now()));
saveNamedQuery(namedQuery1, key("foo1/bar"));
assertHasNamedQuery(namedQuery1);
assertQueryDocumentMapping(/* targetId= */
4, key("foo1/bar"));
Target target2 = Query.atPath(ResourcePath.fromString("foo2")).toTarget();
NamedQuery namedQuery2 = new NamedQuery("query-2", new BundledQuery(target2, Query.LimitType.LIMIT_TO_FIRST), new SnapshotVersion(Timestamp.now()));
saveNamedQuery(namedQuery2, key("foo2/bar"));
assertHasNamedQuery(namedQuery2);
assertQueryDocumentMapping(/* targetId= */
6, key("foo2/bar"));
}
use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.
the class LocalSerializerTest method testEncodesQuery.
@Test
public void testEncodesQuery() {
Target target = new Target(path("room"), /* collectionGroup= */
null, Collections.emptyList(), Collections.emptyList(), Target.NO_LIMIT, /* startAt= */
null, /* endAt= */
null);
BundledQuery bundledQuery = new BundledQuery(target, Query.LimitType.LIMIT_TO_FIRST);
com.google.firestore.bundle.BundledQuery encodedBundledQuery = serializer.encodeBundledQuery(bundledQuery);
BundledQuery decodedBundledQuery = serializer.decodeBundledQuery(encodedBundledQuery);
assertEquals(bundledQuery, decodedBundledQuery);
}
use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.
the class LocalStoreTestCase method testHandlesSavingAndLoadingLimitToLastQueries.
@Test
public void testHandlesSavingAndLoadingLimitToLastQueries() {
Target target = query("foo").orderBy(orderBy("foo")).limitToFirst(// Use `limitToFirst` so toTarget() does not flip ordering constraint
5).toTarget();
NamedQuery namedQuery = new NamedQuery("testQuery", new BundledQuery(target, Query.LimitType.LIMIT_TO_LAST), SnapshotVersion.NONE);
saveNamedQuery(namedQuery);
assertHasNamedQuery(namedQuery);
}
use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.
the class BundleCacheTestCase method testReturnsSavedCollectionGroupQueries.
@Test
public void testReturnsSavedCollectionGroupQueries() {
Target target = new Target(ResourcePath.EMPTY, /* collectionGroup= */
"collectionGroup", Collections.emptyList(), Collections.emptyList(), /* limit= */
1, /* startAt= */
null, /* endAt= */
null);
BundledQuery bundledQuery = new BundledQuery(target, Query.LimitType.LIMIT_TO_FIRST);
NamedQuery expectedQuery = new NamedQuery("query-1", bundledQuery, new SnapshotVersion(Timestamp.now()));
bundleCache.saveNamedQuery(expectedQuery);
NamedQuery actualQuery = bundleCache.getNamedQuery("query-1");
assertEquals(expectedQuery, actualQuery);
}
use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.
the class BundleCacheTestCase method testReturnsSavedCollectionQueries.
@Test
public void testReturnsSavedCollectionQueries() {
Target target = new Target(path("room"), /* collectionGroup= */
null, Collections.emptyList(), Collections.emptyList(), Target.NO_LIMIT, /* startAt= */
null, /* endAt= */
null);
BundledQuery bundledQuery = new BundledQuery(target, Query.LimitType.LIMIT_TO_FIRST);
NamedQuery expectedQuery = new NamedQuery("query-1", bundledQuery, new SnapshotVersion(Timestamp.now()));
bundleCache.saveNamedQuery(expectedQuery);
NamedQuery actualQuery = bundleCache.getNamedQuery("query-1");
assertEquals(expectedQuery, actualQuery);
}
Aggregations