use of com.github.zhenwei.core.asn1.x509.Target in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testEncodesLimits.
@Test
public void testEncodesLimits() {
Query q = Query.atPath(ResourcePath.fromString("docs")).limitToFirst(26);
Target actual = serializer.encodeTarget(wrapTargetData(q));
StructuredQuery.Builder structuredQueryBuilder = StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setCollectionId("docs")).addOrderBy(defaultKeyOrder()).setLimit(Int32Value.newBuilder().setValue(26));
QueryTarget.Builder queryBuilder = QueryTarget.newBuilder().setParent("projects/p/databases/d/documents").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 testEncodesReadTime.
@Test
public void testEncodesReadTime() {
Query q = Query.atPath(ResourcePath.fromString("docs"));
TargetData targetData = new TargetData(q.toTarget(), 1, 2, QueryPurpose.LISTEN).withResumeToken(ByteString.EMPTY, version(4000000));
Target actual = serializer.encodeTarget(targetData);
StructuredQuery.Builder structuredQueryBuilder = StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setCollectionId("docs")).addOrderBy(defaultKeyOrder());
QueryTarget.Builder queryBuilder = QueryTarget.newBuilder().setParent("projects/p/databases/d/documents").setStructuredQuery(structuredQueryBuilder);
Target expected = Target.newBuilder().setQuery(queryBuilder).setTargetId(1).setReadTime(Timestamp.newBuilder().setSeconds(4)).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 testEncodesSortOrdersDescending.
@Test
public void testEncodesSortOrdersDescending() {
Query q = Query.atPath(ResourcePath.fromString("rooms/1/messages/10/attachments")).orderBy(orderBy("prop", "desc"));
Target actual = serializer.encodeTarget(wrapTargetData(q));
StructuredQuery.Builder structuredQueryBuilder = StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setCollectionId("attachments")).addOrderBy(Order.newBuilder().setDirection(Direction.DESCENDING).setField(FieldReference.newBuilder().setFieldPath("prop"))).addOrderBy(Order.newBuilder().setDirection(Direction.DESCENDING).setField(FieldReference.newBuilder().setFieldPath(DocumentKey.KEY_FIELD_NAME)));
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 testEncodesSingleFilterAtFirstLevelCollections.
@Test
public void testEncodesSingleFilterAtFirstLevelCollections() {
Query q = Query.atPath(ResourcePath.fromString("docs")).filter(filter("prop", "<", 42));
Target actual = serializer.encodeTarget(wrapTargetData(q));
StructuredQuery.Builder structuredQueryBuilder = StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setCollectionId("docs")).setWhere(Filter.newBuilder().setFieldFilter(StructuredQuery.FieldFilter.newBuilder().setField(FieldReference.newBuilder().setFieldPath("prop")).setOp(Operator.LESS_THAN).setValue(Value.newBuilder().setIntegerValue(42)))).addOrderBy(Order.newBuilder().setField(FieldReference.newBuilder().setFieldPath("prop")).setDirection(Direction.ASCENDING)).addOrderBy(defaultKeyOrder());
QueryTarget.Builder queryBuilder = QueryTarget.newBuilder().setParent("projects/p/databases/d/documents").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 testEncodesBounds.
@Test
public void testEncodesBounds() {
Query q = Query.atPath(ResourcePath.fromString("docs")).startAt(bound(/* inclusive= */
true, refValue(databaseId, key("foo/bar")))).endAt(bound(/* inclusive= */
true, refValue(databaseId, key("foo/baz"))));
Target actual = serializer.encodeTarget(wrapTargetData(q));
StructuredQuery.Builder structuredQueryBuilder = StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setCollectionId("docs")).addOrderBy(defaultKeyOrder()).setStartAt(Cursor.newBuilder().setBefore(true).addValues(Value.newBuilder().setReferenceValue("projects/p/databases/d/documents/foo/bar"))).setEndAt(Cursor.newBuilder().setBefore(false).addValues(Value.newBuilder().setReferenceValue("projects/p/databases/d/documents/foo/baz")));
QueryTarget.Builder queryBuilder = QueryTarget.newBuilder().setParent("projects/p/databases/d/documents").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());
}
Aggregations