Search in sources :

Example 16 with Target

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());
}
Also used : StructuredQuery(com.google.firestore.v1.StructuredQuery) QueryTarget(com.google.firestore.v1.Target.QueryTarget) DocumentsTarget(com.google.firestore.v1.Target.DocumentsTarget) Target(com.google.firestore.v1.Target) QueryTarget(com.google.firestore.v1.Target.QueryTarget) StructuredQuery(com.google.firestore.v1.StructuredQuery) Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Example 17 with Target

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());
}
Also used : TargetData(com.google.firebase.firestore.local.TargetData) StructuredQuery(com.google.firestore.v1.StructuredQuery) QueryTarget(com.google.firestore.v1.Target.QueryTarget) DocumentsTarget(com.google.firestore.v1.Target.DocumentsTarget) Target(com.google.firestore.v1.Target) QueryTarget(com.google.firestore.v1.Target.QueryTarget) StructuredQuery(com.google.firestore.v1.StructuredQuery) Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Example 18 with Target

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());
}
Also used : StructuredQuery(com.google.firestore.v1.StructuredQuery) QueryTarget(com.google.firestore.v1.Target.QueryTarget) DocumentsTarget(com.google.firestore.v1.Target.DocumentsTarget) Target(com.google.firestore.v1.Target) QueryTarget(com.google.firestore.v1.Target.QueryTarget) StructuredQuery(com.google.firestore.v1.StructuredQuery) Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Example 19 with Target

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());
}
Also used : StructuredQuery(com.google.firestore.v1.StructuredQuery) QueryTarget(com.google.firestore.v1.Target.QueryTarget) DocumentsTarget(com.google.firestore.v1.Target.DocumentsTarget) Target(com.google.firestore.v1.Target) QueryTarget(com.google.firestore.v1.Target.QueryTarget) StructuredQuery(com.google.firestore.v1.StructuredQuery) Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Example 20 with Target

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());
}
Also used : StructuredQuery(com.google.firestore.v1.StructuredQuery) QueryTarget(com.google.firestore.v1.Target.QueryTarget) DocumentsTarget(com.google.firestore.v1.Target.DocumentsTarget) Target(com.google.firestore.v1.Target) QueryTarget(com.google.firestore.v1.Target.QueryTarget) StructuredQuery(com.google.firestore.v1.StructuredQuery) Query(com.google.firebase.firestore.core.Query) Test(org.junit.Test)

Aggregations

Query (com.google.firebase.firestore.core.Query)13 StructuredQuery (com.google.firestore.v1.StructuredQuery)13 Target (com.google.firestore.v1.Target)13 DocumentsTarget (com.google.firestore.v1.Target.DocumentsTarget)13 QueryTarget (com.google.firestore.v1.Target.QueryTarget)13 Test (org.junit.Test)12 CertPathValidatorException (java.security.cert.CertPathValidatorException)5 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)4 PublicKey (java.security.PublicKey)4 PKIXCertPathChecker (java.security.cert.PKIXCertPathChecker)4 PKIXCertPathValidatorResult (java.security.cert.PKIXCertPathValidatorResult)4 PKIXParameters (java.security.cert.PKIXParameters)4 TrustAnchor (java.security.cert.TrustAnchor)4 X509Certificate (java.security.cert.X509Certificate)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 List (java.util.List)4 Set (java.util.Set)4 ExtCertPathValidatorException (com.github.zhenwei.provider.jce.exception.ExtCertPathValidatorException)3