use of com.google.firebase.firestore.core.KeyFieldFilter in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testKeyFieldSerializationEncoding.
@Test
public void testKeyFieldSerializationEncoding() {
FieldFilter inputFilter = filter("__name__", "==", ref("project/database"));
StructuredQuery.Filter apiFilter = serializer.encodeUnaryOrFieldFilter(inputFilter);
StructuredQuery.Filter expectedFilter = Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("__name__")).setOp(Operator.EQUAL).setValue(Value.newBuilder().setReferenceValue("projects/project/databases/(default)/documents/project/database")).build()).build();
assertEquals(expectedFilter, apiFilter);
FieldFilter roundTripped = serializer.decodeFieldFilter(apiFilter.getFieldFilter());
assertEquals(roundTripped, inputFilter);
assertTrue(roundTripped instanceof KeyFieldFilter);
}
Aggregations