GoogleAdsFieldServiceClient implements BackgroundResource { public final SearchGoogleAdsFieldsPagedResponse searchGoogleAdsFields(String query) { SearchGoogleAdsFieldsRequest request = SearchGoogleAdsFieldsRequest.newBuilder().setQuery(query).build(); return searchGoogleAdsFields(request); } protected  GoogleAdsFieldServiceClient(GoogleAdsFieldServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  GoogleAdsFieldServiceClient(GoogleAdsFieldServiceStub stub); static final GoogleAdsFieldServiceClient create(); static final GoogleAdsFieldServiceClient create(GoogleAdsFieldServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final GoogleAdsFieldServiceClient create(GoogleAdsFieldServiceStub stub); final GoogleAdsFieldServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") GoogleAdsFieldServiceStub getStub(); final GoogleAdsField getGoogleAdsField(GoogleAdsFieldName resourceName); final GoogleAdsField getGoogleAdsField(String resourceName); final GoogleAdsField getGoogleAdsField(GetGoogleAdsFieldRequest request); final UnaryCallable<GetGoogleAdsFieldRequest, GoogleAdsField> getGoogleAdsFieldCallable(); final SearchGoogleAdsFieldsPagedResponse searchGoogleAdsFields(String query); final SearchGoogleAdsFieldsPagedResponse searchGoogleAdsFields(
      SearchGoogleAdsFieldsRequest request); final UnaryCallable<SearchGoogleAdsFieldsRequest, SearchGoogleAdsFieldsPagedResponse> searchGoogleAdsFieldsPagedCallable(); final UnaryCallable<SearchGoogleAdsFieldsRequest, SearchGoogleAdsFieldsResponse> searchGoogleAdsFieldsCallable(); @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 searchGoogleAdsFieldsTest() { String nextPageToken = ""; long totalResultsCount = 43694645L; GoogleAdsField resultsElement = GoogleAdsField.newBuilder().build(); List<GoogleAdsField> results = Arrays.asList(resultsElement); SearchGoogleAdsFieldsResponse expectedResponse = SearchGoogleAdsFieldsResponse.newBuilder() .setNextPageToken(nextPageToken) .setTotalResultsCount(totalResultsCount) .addAllResults(results) .build(); mockGoogleAdsFieldService.addResponse(expectedResponse); String query = "query107944136"; SearchGoogleAdsFieldsPagedResponse pagedListResponse = client.searchGoogleAdsFields(query); List<GoogleAdsField> resources = Lists.newArrayList(pagedListResponse.iterateAll()); Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getResultsList().get(0), resources.get(0)); List<AbstractMessage> actualRequests = mockGoogleAdsFieldService.getRequests(); Assert.assertEquals(1, actualRequests.size()); SearchGoogleAdsFieldsRequest actualRequest = (SearchGoogleAdsFieldsRequest) actualRequests.get(0); Assert.assertEquals(query, actualRequest.getQuery()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void searchGoogleAdsFieldsExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockGoogleAdsFieldService.addException(exception); try { String query = "query107944136"; client.searchGoogleAdsFields(query); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }