Search in sources :

Example 1 with KeyFieldFilter

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);
}
Also used : StructuredQuery(com.google.firestore.v1.StructuredQuery) FieldFilter(com.google.firebase.firestore.core.FieldFilter) KeyFieldFilter(com.google.firebase.firestore.core.KeyFieldFilter) KeyFieldFilter(com.google.firebase.firestore.core.KeyFieldFilter) Filter(com.google.firestore.v1.StructuredQuery.Filter) Test(org.junit.Test)

Aggregations

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