Search in sources :

Example 1 with ArrayContainsAnyFilter

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

the class RemoteSerializerTest method testArrayContainsAnySerialization.

@Test
public void testArrayContainsAnySerialization() {
    FieldFilter inputFilter = filter("field", "array-contains-any", asList(42));
    StructuredQuery.Filter apiFilter = serializer.encodeUnaryOrFieldFilter(inputFilter);
    ArrayValue.Builder arrayContainsAnyFilterValue = ArrayValue.newBuilder().addValues(Value.newBuilder().setIntegerValue(42));
    StructuredQuery.Filter expectedFilter = Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("field")).setOp(Operator.ARRAY_CONTAINS_ANY).setValue(Value.newBuilder().setArrayValue(arrayContainsAnyFilterValue)).build()).build();
    assertEquals(expectedFilter, apiFilter);
    FieldFilter roundTripped = serializer.decodeFieldFilter(apiFilter.getFieldFilter());
    assertEquals(roundTripped, inputFilter);
    assertTrue(roundTripped instanceof ArrayContainsAnyFilter);
}
Also used : StructuredQuery(com.google.firestore.v1.StructuredQuery) FieldFilter(com.google.firebase.firestore.core.FieldFilter) KeyFieldFilter(com.google.firebase.firestore.core.KeyFieldFilter) Filter(com.google.firestore.v1.StructuredQuery.Filter) ArrayContainsAnyFilter(com.google.firebase.firestore.core.ArrayContainsAnyFilter) ArrayValue(com.google.firestore.v1.ArrayValue) Test(org.junit.Test)

Aggregations

ArrayContainsAnyFilter (com.google.firebase.firestore.core.ArrayContainsAnyFilter)1 FieldFilter (com.google.firebase.firestore.core.FieldFilter)1 KeyFieldFilter (com.google.firebase.firestore.core.KeyFieldFilter)1 ArrayValue (com.google.firestore.v1.ArrayValue)1 StructuredQuery (com.google.firestore.v1.StructuredQuery)1 Filter (com.google.firestore.v1.StructuredQuery.Filter)1 Test (org.junit.Test)1