use of com.google.firebase.firestore.bundle.NamedQuery 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);
}
use of com.google.firebase.firestore.bundle.NamedQuery 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);
}
use of com.google.firebase.firestore.bundle.NamedQuery in project firebase-android-sdk by firebase.
the class FirestoreClient method getNamedQuery.
public Task<Query> getNamedQuery(String queryName) {
verifyNotTerminated();
TaskCompletionSource<Query> completionSource = new TaskCompletionSource<>();
asyncQueue.enqueueAndForget(() -> {
NamedQuery namedQuery = localStore.getNamedQuery(queryName);
if (namedQuery != null) {
Target target = namedQuery.getBundledQuery().getTarget();
completionSource.setResult(new Query(target.getPath(), target.getCollectionGroup(), target.getFilters(), target.getOrderBy(), target.getLimit(), namedQuery.getBundledQuery().getLimitType(), target.getStartAt(), target.getEndAt()));
} else {
completionSource.setResult(null);
}
});
return completionSource.getTask();
}
use of com.google.firebase.firestore.bundle.NamedQuery in project firebase-android-sdk by firebase.
the class LocalStoreTestCase method assertHasNamedQuery.
private void assertHasNamedQuery(NamedQuery expectedNamedQuery) {
NamedQuery actualNamedQuery = localStore.getNamedQuery(expectedNamedQuery.getName());
assertEquals(expectedNamedQuery, actualNamedQuery);
}
use of com.google.firebase.firestore.bundle.NamedQuery 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);
}
Aggregations