Search in sources :

Example 11 with RunQueryRequest

use of com.google.firestore.v1.RunQueryRequest in project beam by apache.

the class PartitionQueryResponseToRunQueryRequestTest method ensureCursorPairingWorks_emptyCursorsInResponse.

@Test
public void ensureCursorPairingWorks_emptyCursorsInResponse() {
    StructuredQuery query = StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setAllDescendants(true).setCollectionId("c1").build()).build();
    List<StructuredQuery> expectedQueries = newArrayList(query);
    PartitionQueryPair partitionQueryPair = new PartitionQueryPair(PartitionQueryRequest.newBuilder().setStructuredQuery(query).build(), PartitionQueryResponse.newBuilder().build());
    ArgumentCaptor<RunQueryRequest> captor = ArgumentCaptor.forClass(RunQueryRequest.class);
    when(processContext.element()).thenReturn(partitionQueryPair);
    doNothing().when(processContext).output(captor.capture());
    PartitionQueryResponseToRunQueryRequest fn = new PartitionQueryResponseToRunQueryRequest();
    fn.processElement(processContext);
    List<StructuredQuery> actualQueries = captor.getAllValues().stream().map(RunQueryRequest::getStructuredQuery).collect(Collectors.toList());
    assertEquals(expectedQueries, actualQueries);
}
Also used : StructuredQuery(com.google.firestore.v1.StructuredQuery) PartitionQueryResponseToRunQueryRequest(org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.PartitionQuery.PartitionQueryResponseToRunQueryRequest) PartitionQueryPair(org.apache.beam.sdk.io.gcp.firestore.FirestoreV1ReadFn.PartitionQueryPair) RunQueryRequest(com.google.firestore.v1.RunQueryRequest) PartitionQueryResponseToRunQueryRequest(org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.PartitionQuery.PartitionQueryResponseToRunQueryRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 RunQueryRequest (com.google.datastore.v1.RunQueryRequest)6 GqlQuery (com.google.datastore.v1.GqlQuery)5 RunQueryRequest (com.google.firestore.v1.RunQueryRequest)5 Query (com.google.datastore.v1.Query)3 RunQueryResponse (com.google.firestore.v1.RunQueryResponse)3 StructuredQuery (com.google.firestore.v1.StructuredQuery)3 Entity (com.google.datastore.v1.Entity)2 RunQueryResponse (com.google.datastore.v1.RunQueryResponse)2 DatastoreException (com.google.datastore.v1.client.DatastoreException)2 Cursor (com.google.firestore.v1.Cursor)2 Document (com.google.firestore.v1.Document)2 FieldReference (com.google.firestore.v1.StructuredQuery.FieldReference)2 DeleteEntity (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteEntity)2 ReadFn (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.Read.ReadFn)2 PartitionQueryResponseToRunQueryRequest (org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.PartitionQuery.PartitionQueryResponseToRunQueryRequest)2 PartitionQueryPair (org.apache.beam.sdk.io.gcp.firestore.FirestoreV1ReadFn.PartitionQueryPair)2 RunQueryFn (org.apache.beam.sdk.io.gcp.firestore.FirestoreV1ReadFn.RunQueryFn)2 ServerStream (com.google.api.gax.rpc.ServerStream)1 ServerStreamingCallable (com.google.api.gax.rpc.ServerStreamingCallable)1