Search in sources :

Example 86 with Query

use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.

the class BundleSerializerTest method testDecodesEndBeforeQuery.

@Test
public void testDecodesEndBeforeQuery() throws JSONException {
    String json = "{\n" + "from: [ { collectionId: 'coll' } ],\n" + "orderBy: [ { field: { fieldPath: 'foo' } } ],\n" + "endAt: { values: [ { stringValue: 'bar' } ], before: true } }";
    Query query = TestUtil.query("coll").orderBy(orderBy("foo")).endAt(bound(/* inclusive= */
    false, "bar"));
    assertDecodesNamedQuery(json, query);
}
Also used : Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Example 87 with Query

use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.

the class BundleSerializerTest method testDecodesGreaterThanFilter.

@Test
public void testDecodesGreaterThanFilter() throws JSONException {
    String json = "{\n" + "from: [ { collectionId: 'coll' } ],\n" + "where: {\n" + "  fieldFilter: {\n" + "    op: 'GREATER_THAN', field: { fieldPath: 'f1' }, value: { stringValue: 'foo' }\n" + "  }\n" + "} }";
    Query query = TestUtil.query("coll").filter(filter("f1", ">", "foo"));
    assertDecodesNamedQuery(json, query);
}
Also used : Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Example 88 with Query

use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.

the class BundleSerializerTest method testDoesNotDecodeMultipleCollections.

@Test
public void testDoesNotDecodeMultipleCollections() throws JSONException {
    String json = "{ from: [ { collectionId: 'c1' }, { collectionId: 'c2' } ] }";
    Query query = TestUtil.query("coll");
    assertThrows(IllegalArgumentException.class, () -> assertDecodesNamedQuery(json, query));
}
Also used : Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Example 89 with Query

use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.

the class BundleSerializerTest method testDecodesArrayContainsFilter.

@Test
public void testDecodesArrayContainsFilter() throws JSONException {
    String json = "{\n" + "from: [ { collectionId: 'coll' } ],\n" + "where: {\n" + "  fieldFilter: {\n" + "    op: 'ARRAY_CONTAINS',\n" + "    field: { fieldPath: 'f1' },\n" + "    value: { stringValue: 'foo' }\n" + "  }\n" + "} }";
    Query query = TestUtil.query("coll").filter(filter("f1", "array-contains", "foo"));
    assertDecodesNamedQuery(json, query);
}
Also used : Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Example 90 with Query

use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.

the class BundleSerializerTest method testDecodesArrayContainsAnyFilter.

@Test
public void testDecodesArrayContainsAnyFilter() throws JSONException {
    String json = "{\n" + "from: [ { collectionId: 'coll' } ],\n" + "where: {\n" + "  fieldFilter: {\n" + "    op: 'ARRAY_CONTAINS_ANY',\n" + "    field: { fieldPath: 'f1' },\n" + "    value: { arrayValue: { values: [ { stringValue: 'foo' } ] } }\n" + "  }\n" + "} }";
    Query query = TestUtil.query("coll").filter(filter("f1", "array-contains-any", Collections.singletonList("foo")));
    assertDecodesNamedQuery(json, query);
}
Also used : Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Aggregations

Query (com.google.firebase.firestore.core.Query)205 Test (org.junit.Test)195 BundledQuery (com.google.firebase.firestore.bundle.BundledQuery)42 NamedQuery (com.google.firebase.firestore.bundle.NamedQuery)41 DocumentSet (com.google.firebase.firestore.model.DocumentSet)18 StructuredQuery (com.google.firestore.v1.StructuredQuery)16 Target (com.google.firestore.v1.Target)13 DocumentsTarget (com.google.firestore.v1.Target.DocumentsTarget)13 QueryTarget (com.google.firestore.v1.Target.QueryTarget)13 MutableDocument (com.google.firebase.firestore.model.MutableDocument)12 FieldIndex (com.google.firebase.firestore.model.FieldIndex)8 TargetData (com.google.firebase.firestore.local.TargetData)7 ArrayList (java.util.ArrayList)7 DocumentKey (com.google.firebase.firestore.model.DocumentKey)5 ByteString (com.google.protobuf.ByteString)5 HashMap (java.util.HashMap)4 Document (com.google.firebase.firestore.model.Document)3 SnapshotVersion (com.google.firebase.firestore.model.SnapshotVersion)3 Timestamp (com.google.firebase.Timestamp)2 QueryListener (com.google.firebase.firestore.core.QueryListener)2