use of com.google.firestore.v1.ListenResponse in project java-firestore by googleapis.
the class FirestoreClientTest method listenExceptionTest.
@Test
public void listenExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
ListenRequest request = ListenRequest.newBuilder().setDatabase("database1789464955").putAllLabels(new HashMap<String, String>()).build();
MockStreamObserver<ListenResponse> responseObserver = new MockStreamObserver<>();
BidiStreamingCallable<ListenRequest, ListenResponse> callable = client.listenCallable();
ApiStreamObserver<ListenRequest> requestObserver = callable.bidiStreamingCall(responseObserver);
requestObserver.onNext(request);
try {
List<ListenResponse> 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