Search in sources :

Example 1 with BundledQuery

use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.

the class BundleCacheTestCase method testReturnsSavedLimitToFirstQueries.

@Test
public void testReturnsSavedLimitToFirstQueries() {
    Target target = new Target(path("room"), /* collectionGroup= */
    null, 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);
}
Also used : Target(com.google.firebase.firestore.core.Target) SnapshotVersion(com.google.firebase.firestore.model.SnapshotVersion) BundledQuery(com.google.firebase.firestore.bundle.BundledQuery) NamedQuery(com.google.firebase.firestore.bundle.NamedQuery) Test(org.junit.Test)

Example 2 with BundledQuery

use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.

the class BundleCacheTestCase method testReturnsSavedLimitToLastQueries.

@Test
public void testReturnsSavedLimitToLastQueries() {
    Target target = new Target(path("room"), /* collectionGroup= */
    null, Collections.emptyList(), Collections.emptyList(), /* limit= */
    1, /* startAt= */
    null, /* endAt= */
    null);
    BundledQuery bundledQuery = new BundledQuery(target, Query.LimitType.LIMIT_TO_LAST);
    NamedQuery expectedQuery = new NamedQuery("query-1", bundledQuery, new SnapshotVersion(Timestamp.now()));
    bundleCache.saveNamedQuery(expectedQuery);
    NamedQuery actualQuery = bundleCache.getNamedQuery("query-1");
    assertEquals(expectedQuery, actualQuery);
}
Also used : Target(com.google.firebase.firestore.core.Target) SnapshotVersion(com.google.firebase.firestore.model.SnapshotVersion) BundledQuery(com.google.firebase.firestore.bundle.BundledQuery) NamedQuery(com.google.firebase.firestore.bundle.NamedQuery) Test(org.junit.Test)

Example 3 with BundledQuery

use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.

the class LocalSerializerTest method testEncodesLimitToLastQuery.

@Test
public void testEncodesLimitToLastQuery() {
    Target target = new Target(path("room"), /* collectionGroup= */
    null, Collections.emptyList(), Collections.emptyList(), /* limit=*/
    42, /* startAt= */
    null, /* endAt= */
    null);
    BundledQuery bundledQuery = new BundledQuery(target, Query.LimitType.LIMIT_TO_LAST);
    com.google.firestore.bundle.BundledQuery encodedBundledQuery = serializer.encodeBundledQuery(bundledQuery);
    BundledQuery decodedBundledQuery = serializer.decodeBundledQuery(encodedBundledQuery);
    assertEquals(bundledQuery, decodedBundledQuery);
}
Also used : Target(com.google.firebase.firestore.core.Target) BundledQuery(com.google.firebase.firestore.bundle.BundledQuery) Test(org.junit.Test)

Example 4 with BundledQuery

use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.

the class LocalSerializer method decodeBundledQuery.

public BundledQuery decodeBundledQuery(com.google.firestore.bundle.BundledQuery bundledQuery) {
    LimitType limitType = bundledQuery.getLimitType().equals(com.google.firestore.bundle.BundledQuery.LimitType.FIRST) ? LimitType.LIMIT_TO_FIRST : LimitType.LIMIT_TO_LAST;
    Target target = rpcSerializer.decodeQueryTarget(bundledQuery.getParent(), bundledQuery.getStructuredQuery());
    return new BundledQuery(target, limitType);
}
Also used : Target(com.google.firebase.firestore.core.Target) BundledQuery(com.google.firebase.firestore.bundle.BundledQuery) LimitType(com.google.firebase.firestore.core.Query.LimitType)

Example 5 with BundledQuery

use of com.google.firebase.firestore.bundle.BundledQuery in project firebase-android-sdk by firebase.

the class LocalStoreTestCase method testHandlesSavingAndLoadingNamedQueries.

@Test
public void testHandlesSavingAndLoadingNamedQueries() {
    Target target = query("foo").toTarget();
    NamedQuery namedQuery = new NamedQuery("testQuery", new BundledQuery(target, Query.LimitType.LIMIT_TO_FIRST), SnapshotVersion.NONE);
    saveNamedQuery(namedQuery);
    assertHasNamedQuery(namedQuery);
}
Also used : Target(com.google.firebase.firestore.core.Target) BundledQuery(com.google.firebase.firestore.bundle.BundledQuery) NamedQuery(com.google.firebase.firestore.bundle.NamedQuery) Test(org.junit.Test)

Aggregations

BundledQuery (com.google.firebase.firestore.bundle.BundledQuery)10 Target (com.google.firebase.firestore.core.Target)10 Test (org.junit.Test)9 NamedQuery (com.google.firebase.firestore.bundle.NamedQuery)7 SnapshotVersion (com.google.firebase.firestore.model.SnapshotVersion)5 LimitType (com.google.firebase.firestore.core.Query.LimitType)1