Search in sources :

Example 21 with Target

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());
}
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 22 with Target

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());
}
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 23 with Target

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());
}
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