use of com.google.firestore.v1beta1.BatchGetDocumentsResponse in project beam by apache.
the class FirestoreV1FnBatchGetDocumentsTest method endToEnd.
@Test
public void endToEnd() throws Exception {
final BatchGetDocumentsRequest request = BatchGetDocumentsRequest.newBuilder().setDatabase(String.format("projects/%s/databases/(default)", projectId)).addDocuments("doc_1-1").addDocuments("doc_1-2").addDocuments("doc_1-3").build();
final BatchGetDocumentsResponse response1 = newFound(1);
final BatchGetDocumentsResponse response2 = newFound(2);
final BatchGetDocumentsResponse response3 = newFound(3);
List<BatchGetDocumentsResponse> responses = ImmutableList.of(response1, response2, response3);
when(responseStream1.iterator()).thenReturn(responses.iterator());
when(callable.call(request)).thenReturn(responseStream1);
when(stub.batchGetDocumentsCallable()).thenReturn(callable);
when(ff.getFirestoreStub(any())).thenReturn(stub);
when(ff.getRpcQos(any())).thenReturn(FirestoreStatefulComponentFactory.INSTANCE.getRpcQos(rpcQosOptions));
ArgumentCaptor<BatchGetDocumentsResponse> responsesCaptor = ArgumentCaptor.forClass(BatchGetDocumentsResponse.class);
doNothing().when(processContext).output(responsesCaptor.capture());
when(processContext.element()).thenReturn(request);
runFunction(getFn(clock, ff, rpcQosOptions));
List<BatchGetDocumentsResponse> allValues = responsesCaptor.getAllValues();
assertEquals(responses, allValues);
}
use of com.google.firestore.v1beta1.BatchGetDocumentsResponse in project java-firestore by googleapis.
the class FirestoreClientTest method batchGetDocumentsExceptionTest.
@Test
public void batchGetDocumentsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
BatchGetDocumentsRequest request = BatchGetDocumentsRequest.newBuilder().setDatabase("database1789464955").addAllDocuments(new ArrayList<String>()).setMask(DocumentMask.newBuilder().build()).build();
MockStreamObserver<BatchGetDocumentsResponse> responseObserver = new MockStreamObserver<>();
ServerStreamingCallable<BatchGetDocumentsRequest, BatchGetDocumentsResponse> callable = client.batchGetDocumentsCallable();
callable.serverStreamingCall(request, responseObserver);
try {
List<BatchGetDocumentsResponse> actualResponses = responseObserver.future().get();
Assert.fail("No exception thrown");
} catch (ExecutionException e) {
Assert.assertTrue(e.getCause() instanceof InvalidArgumentException);
InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
Aggregations