Search in sources :

Example 1 with InFilter

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

the class RemoteSerializerTest method testInSerialization.

@Test
public void testInSerialization() {
    FieldFilter inputFilter = filter("field", "in", asList(42));
    StructuredQuery.Filter apiFilter = serializer.encodeUnaryOrFieldFilter(inputFilter);
    ArrayValue.Builder inFilterValue = ArrayValue.newBuilder().addValues(Value.newBuilder().setIntegerValue(42));
    StructuredQuery.Filter expectedFilter = Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("field")).setOp(Operator.IN).setValue(Value.newBuilder().setArrayValue(inFilterValue)).build()).build();
    assertEquals(expectedFilter, apiFilter);
    FieldFilter roundTripped = serializer.decodeFieldFilter(apiFilter.getFieldFilter());
    assertEquals(roundTripped, inputFilter);
    assertTrue(roundTripped instanceof InFilter);
}
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) ArrayValue(com.google.firestore.v1.ArrayValue) NotInFilter(com.google.firebase.firestore.core.NotInFilter) InFilter(com.google.firebase.firestore.core.InFilter) Test(org.junit.Test)

Aggregations

FieldFilter (com.google.firebase.firestore.core.FieldFilter)1 InFilter (com.google.firebase.firestore.core.InFilter)1 KeyFieldFilter (com.google.firebase.firestore.core.KeyFieldFilter)1 NotInFilter (com.google.firebase.firestore.core.NotInFilter)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