use of com.google.firebase.firestore.core.NotInFilter in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testNotInSerialization.
@Test
public void testNotInSerialization() {
FieldFilter inputFilter = filter("field", "not-in", asList(42));
StructuredQuery.Filter apiFilter = serializer.encodeUnaryOrFieldFilter(inputFilter);
ArrayValue.Builder notInFilterValue = ArrayValue.newBuilder().addValues(Value.newBuilder().setIntegerValue(42));
StructuredQuery.Filter expectedFilter = Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("field")).setOp(Operator.NOT_IN).setValue(Value.newBuilder().setArrayValue(notInFilterValue)).build()).build();
assertEquals(expectedFilter, apiFilter);
FieldFilter roundTripped = serializer.decodeFieldFilter(apiFilter.getFieldFilter());
assertEquals(roundTripped, inputFilter);
assertTrue(roundTripped instanceof NotInFilter);
}
use of com.google.firebase.firestore.core.NotInFilter in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testNotInWithNullSerialization.
@Test
public void testNotInWithNullSerialization() {
List<Object> nullArray = new ArrayList<>();
nullArray.add(null);
FieldFilter inputFilter = filter("field", "not-in", nullArray);
StructuredQuery.Filter apiFilter = serializer.encodeUnaryOrFieldFilter(inputFilter);
ArrayValue.Builder notInFilterValue = ArrayValue.newBuilder().addValues(Value.newBuilder().setNullValue(NullValue.NULL_VALUE));
StructuredQuery.Filter expectedFilter = Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("field")).setOp(Operator.NOT_IN).setValue(Value.newBuilder().setArrayValue(notInFilterValue)).build()).build();
assertEquals(expectedFilter, apiFilter);
FieldFilter roundTripped = serializer.decodeFieldFilter(apiFilter.getFieldFilter());
assertEquals(roundTripped, inputFilter);
assertTrue(roundTripped instanceof NotInFilter);
}
Aggregations