Search in sources :

Example 6 with Builder

use of com.google.firestore.v1.Document.Builder in project spring-cloud-gcp by spring-cloud.

the class FirestoreTemplateTests method countWithQueryTest.

@Test
public void countWithQueryTest() {
    mockRunQueryMethod();
    StructuredQuery.Builder builder = StructuredQuery.newBuilder();
    addWhere(builder);
    StepVerifier.create(this.firestoreTemplate.count(TestEntity.class, builder)).expectNext(2L).verifyComplete();
    StructuredQuery.Builder expectedBuilder = StructuredQuery.newBuilder().addFrom(StructuredQuery.CollectionSelector.newBuilder().setCollectionId("testEntities").build()).setSelect(StructuredQuery.Projection.newBuilder().addFields(StructuredQuery.FieldReference.newBuilder().setFieldPath("__name__").build()).build());
    addWhere(expectedBuilder);
    RunQueryRequest request = RunQueryRequest.newBuilder().setParent(this.parent).setStructuredQuery(expectedBuilder).build();
    verify(this.firestoreStub, times(1)).runQuery(eq(request), any());
    verify(this.firestoreStub, times(1)).runQuery(any(), any());
}
Also used : StructuredQuery(com.google.firestore.v1.StructuredQuery) RunQueryRequest(com.google.firestore.v1.RunQueryRequest) Test(org.junit.Test)

Aggregations

StructuredQuery (com.google.firestore.v1.StructuredQuery)3 BatchWriteRequest (com.google.firestore.v1.BatchWriteRequest)2 BatchWriteResponse (com.google.firestore.v1.BatchWriteResponse)2 Write (com.google.firestore.v1.Write)2 FirestoreProtoHelpers.newWrite (org.apache.beam.sdk.io.gcp.firestore.FirestoreProtoHelpers.newWrite)2 WriteElement (org.apache.beam.sdk.io.gcp.firestore.FirestoreV1WriteFn.WriteElement)2 Element (org.apache.beam.sdk.io.gcp.firestore.RpcQos.RpcWriteAttempt.Element)2 Test (org.junit.Test)2 GrpcStatusCode (com.google.api.gax.grpc.GrpcStatusCode)1 ApiException (com.google.api.gax.rpc.ApiException)1 ApiExceptionFactory (com.google.api.gax.rpc.ApiExceptionFactory)1 UnaryCallable (com.google.api.gax.rpc.UnaryCallable)1 Document (com.google.firestore.v1.Document)1 RunQueryRequest (com.google.firestore.v1.RunQueryRequest)1 FieldReference (com.google.firestore.v1.StructuredQuery.FieldReference)1 Builder (com.google.firestore.v1.Write.Builder)1 WriteResult (com.google.firestore.v1.WriteResult)1 Code (com.google.rpc.Code)1 Status (com.google.rpc.Status)1 IOException (java.io.IOException)1