use of com.google.firestore.v1beta1.BatchGetDocumentsRequest 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());
}
}
use of com.google.firestore.v1beta1.BatchGetDocumentsRequest in project java-firestore by googleapis.
the class FirestoreTest method getAllWithFieldMask.
@Test
public void getAllWithFieldMask() throws Exception {
doAnswer(getAllResponse(SINGLE_FIELD_PROTO)).when(firestoreMock).streamRequest(getAllCapture.capture(), streamObserverCapture.capture(), Matchers.<ServerStreamingCallable>any());
DocumentReference doc1 = firestoreMock.document("coll/doc1");
FieldMask fieldMask = FieldMask.of(FieldPath.of("foo", "bar"));
firestoreMock.getAll(new DocumentReference[] { doc1 }, fieldMask).get();
BatchGetDocumentsRequest request = getAllCapture.getValue();
assertEquals(1, request.getMask().getFieldPathsCount());
assertEquals("foo.bar", request.getMask().getFieldPaths(0));
}
use of com.google.firestore.v1beta1.BatchGetDocumentsRequest in project java-firestore by googleapis.
the class LocalFirestoreHelper method getAll.
public static BatchGetDocumentsRequest getAll(@Nullable String transactionId, String... documentNames) {
BatchGetDocumentsRequest.Builder request = BatchGetDocumentsRequest.newBuilder();
request.setDatabase(DATABASE_NAME);
for (String documentName : documentNames) {
request.addDocuments(documentName);
}
if (transactionId != null) {
request.setTransaction(ByteString.copyFromUtf8(transactionId));
}
return request.build();
}
Aggregations