use of com.github.zhenwei.core.asn1.x509.Target in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testEncodesNestedAncestorQueries.
@Test
public void testEncodesNestedAncestorQueries() {
Query q = Query.atPath(ResourcePath.fromString("rooms/1/messages/10/attachments"));
Target actual = serializer.encodeTarget(wrapTargetData(q));
StructuredQuery.Builder structuredQueryBuilder = StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setCollectionId("attachments")).addOrderBy(defaultKeyOrder());
QueryTarget queryBuilder = QueryTarget.newBuilder().setParent("projects/p/databases/d/documents/rooms/1/messages/10").setStructuredQuery(structuredQueryBuilder).build();
Target expected = Target.newBuilder().setQuery(queryBuilder).setTargetId(1).setResumeToken(ByteString.EMPTY).build();
assertEquals(expected, actual);
assertEquals(serializer.decodeQueryTarget(serializer.encodeQueryTarget(q.toTarget())), q.toTarget());
}
use of com.github.zhenwei.core.asn1.x509.Target in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testEncodesMultipleFiltersOnDeeperCollections.
@Test
public void testEncodesMultipleFiltersOnDeeperCollections() {
Query q = Query.atPath(ResourcePath.fromString("rooms/1/messages/10/attachments")).filter(filter("prop", "<", 42)).filter(filter("author", "==", "dimond")).filter(filter("tags", "array-contains", "pending"));
Target actual = serializer.encodeTarget(wrapTargetData(q));
StructuredQuery.Builder structuredQueryBuilder = StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setCollectionId("attachments")).setWhere(Filter.newBuilder().setCompositeFilter(StructuredQuery.CompositeFilter.newBuilder().setOp(CompositeFilter.Operator.AND).addFilters(Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("prop")).setOp(Operator.LESS_THAN).setValue(Value.newBuilder().setIntegerValue(42)))).addFilters(Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("author")).setOp(Operator.EQUAL).setValue(Value.newBuilder().setStringValue("dimond")))).addFilters(Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("tags")).setOp(Operator.ARRAY_CONTAINS).setValue(Value.newBuilder().setStringValue("pending")))))).addOrderBy(Order.newBuilder().setField(FieldReference.newBuilder().setFieldPath("prop")).setDirection(Direction.ASCENDING)).addOrderBy(defaultKeyOrder());
QueryTarget.Builder queryBuilder = QueryTarget.newBuilder().setParent("projects/p/databases/d/documents/rooms/1/messages/10").setStructuredQuery(structuredQueryBuilder);
Target expected = Target.newBuilder().setQuery(queryBuilder).setTargetId(1).setResumeToken(ByteString.EMPTY).build();
assertEquals(expected, actual);
assertEquals(serializer.decodeQueryTarget(serializer.encodeQueryTarget(q.toTarget())), q.toTarget());
}
use of com.github.zhenwei.core.asn1.x509.Target in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testEncodesCompositeFiltersOnDeeperCollections.
@Test
public void testEncodesCompositeFiltersOnDeeperCollections() {
// (prop < 42) || (author == "ehsann" && tags array-contains "pending")
Query q = Query.atPath(ResourcePath.fromString("rooms/1/messages/10/attachments")).filter(orFilters(filter("prop", "<", 42), andFilters(filter("author", "==", "ehsann"), filter("tags", "array-contains", "pending"))));
Target actual = serializer.encodeTarget(wrapTargetData(q));
StructuredQuery.Builder structuredQueryBuilder = StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setCollectionId("attachments")).setWhere(Filter.newBuilder().setCompositeFilter(StructuredQuery.CompositeFilter.newBuilder().setOp(CompositeFilter.Operator.OPERATOR_UNSPECIFIED).addFilters(Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("prop")).setOp(Operator.LESS_THAN).setValue(Value.newBuilder().setIntegerValue(42)))).addFilters(Filter.newBuilder().setCompositeFilter(StructuredQuery.CompositeFilter.newBuilder().setOp(CompositeFilter.Operator.AND).addFilters(Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("author")).setOp(Operator.EQUAL).setValue(Value.newBuilder().setStringValue("ehsann")))).addFilters(Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("tags")).setOp(Operator.ARRAY_CONTAINS).setValue(Value.newBuilder().setStringValue("pending")))))))).addOrderBy(Order.newBuilder().setField(FieldReference.newBuilder().setFieldPath("prop")).setDirection(Direction.ASCENDING)).addOrderBy(defaultKeyOrder());
QueryTarget.Builder queryBuilder = QueryTarget.newBuilder().setParent("projects/p/databases/d/documents/rooms/1/messages/10").setStructuredQuery(structuredQueryBuilder);
Target expected = Target.newBuilder().setQuery(queryBuilder).setTargetId(1).setResumeToken(ByteString.EMPTY).build();
assertEquals(expected, actual);
com.google.firebase.firestore.core.Target roundTripped = serializer.decodeQueryTarget(serializer.encodeQueryTarget(q.toTarget()));
assertEquals(roundTripped, q.toTarget());
}
Aggregations