GoogleAdsServiceClient implements BackgroundResource { public final ServerStreamingCallable<SearchGoogleAdsStreamRequest, SearchGoogleAdsStreamResponse> searchStreamCallable() { return stub.searchStreamCallable(); } protected  GoogleAdsServiceClient(GoogleAdsServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  GoogleAdsServiceClient(GoogleAdsServiceStub stub); static final GoogleAdsServiceClient create(); static final GoogleAdsServiceClient create(GoogleAdsServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final GoogleAdsServiceClient create(GoogleAdsServiceStub stub); final GoogleAdsServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") GoogleAdsServiceStub getStub(); final SearchPagedResponse search(String customerId, String query); final SearchPagedResponse search(SearchGoogleAdsRequest request); final UnaryCallable<SearchGoogleAdsRequest, SearchPagedResponse> searchPagedCallable(); final UnaryCallable<SearchGoogleAdsRequest, SearchGoogleAdsResponse> searchCallable(); final ServerStreamingCallable<SearchGoogleAdsStreamRequest, SearchGoogleAdsStreamResponse> searchStreamCallable(); final MutateGoogleAdsResponse mutate(
      String customerId, List<MutateOperation> mutateOperations); final MutateGoogleAdsResponse mutate(MutateGoogleAdsRequest request); final UnaryCallable<MutateGoogleAdsRequest, MutateGoogleAdsResponse> mutateCallable(); @Override final void close(); @Override void shutdown(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override void shutdownNow(); @Override boolean awaitTermination(long duration, TimeUnit unit);  }
@Test @SuppressWarnings("all") public void searchStreamTest() throws Exception { SearchGoogleAdsStreamResponse expectedResponse = SearchGoogleAdsStreamResponse.newBuilder().build(); mockGoogleAdsService.addResponse(expectedResponse); String customerId = "customerId-1772061412"; String query = "query107944136"; SearchGoogleAdsStreamRequest request = SearchGoogleAdsStreamRequest.newBuilder().setCustomerId(customerId).setQuery(query).build(); MockStreamObserver<SearchGoogleAdsStreamResponse> responseObserver = new MockStreamObserver<>(); ServerStreamingCallable<SearchGoogleAdsStreamRequest, SearchGoogleAdsStreamResponse> callable = client.searchStreamCallable(); callable.serverStreamingCall(request, responseObserver); List<SearchGoogleAdsStreamResponse> actualResponses = responseObserver.future().get(); Assert.assertEquals(1, actualResponses.size()); Assert.assertEquals(expectedResponse, actualResponses.get(0)); }
@Test @SuppressWarnings("all") public void searchStreamExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockGoogleAdsService.addException(exception); String customerId = "customerId-1772061412"; String query = "query107944136"; SearchGoogleAdsStreamRequest request = SearchGoogleAdsStreamRequest.newBuilder().setCustomerId(customerId).setQuery(query).build(); MockStreamObserver<SearchGoogleAdsStreamResponse> responseObserver = new MockStreamObserver<>(); ServerStreamingCallable<SearchGoogleAdsStreamRequest, SearchGoogleAdsStreamResponse> callable = client.searchStreamCallable(); callable.serverStreamingCall(request, responseObserver); try { List<SearchGoogleAdsStreamResponse> 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()); } }