use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteQueryEngineTest method testRefillsIndexedLimitQueries.
@Test
public void testRefillsIndexedLimitQueries() throws Exception {
MutableDocument doc1 = doc("coll/1", 1, map("a", 1));
MutableDocument doc2 = doc("coll/2", 1, map("a", 2));
MutableDocument doc3 = doc("coll/3", 1, map("a", 3));
MutableDocument doc4 = doc("coll/4", 1, map("a", 4));
addDocument(doc1, doc2, doc3, doc4);
indexManager.addFieldIndex(fieldIndex("coll", "a", Kind.ASCENDING));
indexManager.updateIndexEntries(docMap(doc1, doc2, doc3, doc4));
indexManager.updateCollectionGroup("coll", IndexOffset.fromDocument(doc4));
addMutation(patchMutation("coll/3", map("a", 5)));
Query query = query("coll").orderBy(orderBy("a")).limitToFirst(3);
DocumentSet result = expectOptimizedCollectionScan(() -> runQuery(query, SnapshotVersion.NONE));
assertEquals(docSet(query.comparator(), doc1, doc2, doc4), result);
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class BundleSerializerTest method testDecodesCollectionQuery.
// Query decoding tests
@Test
public void testDecodesCollectionQuery() throws JSONException {
String json = "{ from: [ { collectionId: 'coll' } ] }";
Query query = TestUtil.query("coll");
assertDecodesNamedQuery(json, query);
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class BundleSerializerTest method testDecodesGreaterThanOrEqualFilter.
@Test
public void testDecodesGreaterThanOrEqualFilter() throws JSONException {
String json = "{\n" + "from: [ { collectionId: 'coll' } ],\n" + "where: {\n" + " fieldFilter: {\n" + " op: 'GREATER_THAN_OR_EQUAL',\n" + " field: { fieldPath: 'f1' },\n" + " value: { stringValue: 'foo' }\n" + " }\n" + "} }";
Query query = TestUtil.query("coll").filter(filter("f1", ">=", "foo"));
assertDecodesNamedQuery(json, query);
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class BundleSerializerTest method testDecodesNotInFilter.
@Test
public void testDecodesNotInFilter() throws JSONException {
String json = "{\n" + "from: [ { collectionId: 'coll' } ],\n" + "where: {\n" + " fieldFilter: {\n" + " op: 'NOT_IN',\n" + " field: { fieldPath: 'f1' },\n" + " value: { arrayValue: { values: [ { stringValue: 'foo' } ] } }\n" + " }" + "} }";
Query query = TestUtil.query("coll").filter(filter("f1", "not-in", Collections.singletonList("foo")));
assertDecodesNamedQuery(json, query);
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class BundleSerializerTest method testDecodeOrderByQuery.
@Test
public void testDecodeOrderByQuery() throws JSONException {
String json = "{\n" + "from: [ { collectionId: 'coll' } ],\n" + "orderBy: [\n" + " { field: { fieldPath: 'f1' }},\n" + " { field: { fieldPath: 'f2' }, direction: 'ASCENDING' },\n" + " { field: { fieldPath: 'f3' }, direction: 'DESCENDING' }\n" + "]}";
Query query = TestUtil.query("coll").orderBy(orderBy("f1")).orderBy(orderBy("f2", "asc")).orderBy(orderBy("f3", "desc"));
assertDecodesNamedQuery(json, query);
}
Aggregations