GoogleAdsFieldServiceClient implements BackgroundResource { public final GoogleAdsField getGoogleAdsField(GoogleAdsFieldName resourceName) { GetGoogleAdsFieldRequest request = GetGoogleAdsFieldRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getGoogleAdsField(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 getGoogleAdsFieldTest() { com.google.ads.googleads.v5.services.GoogleAdsFieldName resourceName2 = com.google.ads.googleads.v5.services.GoogleAdsFieldName.of("[GOOGLE_ADS_FIELD]"); com.google.ads.googleads.v5.services.GoogleAdsFieldName name = com.google.ads.googleads.v5.services.GoogleAdsFieldName.of("[GOOGLE_ADS_FIELD]"); boolean selectable = true; boolean filterable = true; boolean sortable = true; String typeUrl = "typeUrl-675981590"; boolean isRepeated = false; GoogleAdsField expectedResponse = GoogleAdsField.newBuilder() .setResourceName(resourceName2.toString()) .setName(name.toString()) .setSelectable(selectable) .setFilterable(filterable) .setSortable(sortable) .setTypeUrl(typeUrl) .setIsRepeated(isRepeated) .build(); mockGoogleAdsFieldService.addResponse(expectedResponse); GoogleAdsFieldName resourceName = GoogleAdsFieldName.of("[GOOGLE_ADS_FIELD]"); GoogleAdsField actualResponse = client.getGoogleAdsField(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockGoogleAdsFieldService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetGoogleAdsFieldRequest actualRequest = (GetGoogleAdsFieldRequest) actualRequests.get(0); Assert.assertEquals(resourceName, GoogleAdsFieldName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getGoogleAdsFieldExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockGoogleAdsFieldService.addException(exception); try { GoogleAdsFieldName resourceName = GoogleAdsFieldName.of("[GOOGLE_ADS_FIELD]"); client.getGoogleAdsField(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }