AdGroupAdServiceClient implements BackgroundResource { public final AdGroupAd getAdGroupAd(AdGroupAdName resourceName) { GetAdGroupAdRequest request = GetAdGroupAdRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getAdGroupAd(request); } protected  AdGroupAdServiceClient(AdGroupAdServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  AdGroupAdServiceClient(AdGroupAdServiceStub stub); static final AdGroupAdServiceClient create(); static final AdGroupAdServiceClient create(AdGroupAdServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final AdGroupAdServiceClient create(AdGroupAdServiceStub stub); final AdGroupAdServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") AdGroupAdServiceStub getStub(); final AdGroupAd getAdGroupAd(AdGroupAdName resourceName); final AdGroupAd getAdGroupAd(String resourceName); final AdGroupAd getAdGroupAd(GetAdGroupAdRequest request); final UnaryCallable<GetAdGroupAdRequest, AdGroupAd> getAdGroupAdCallable(); final MutateAdGroupAdsResponse mutateAdGroupAds(
      String customerId, List<AdGroupAdOperation> operations); final MutateAdGroupAdsResponse mutateAdGroupAds(MutateAdGroupAdsRequest request); final UnaryCallable<MutateAdGroupAdsRequest, MutateAdGroupAdsResponse> mutateAdGroupAdsCallable(); @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 getAdGroupAdTest() { com.google.ads.googleads.v5.services.AdGroupAdName resourceName2 = com.google.ads.googleads.v5.services.AdGroupAdName.of("[CUSTOMER]", "[AD_GROUP_AD]"); AdGroupName adGroup = AdGroupName.of("[CUSTOMER]", "[AD_GROUP]"); AdGroupAd expectedResponse = AdGroupAd.newBuilder() .setResourceName(resourceName2.toString()) .setAdGroup(adGroup.toString()) .build(); mockAdGroupAdService.addResponse(expectedResponse); AdGroupAdName resourceName = AdGroupAdName.of("[CUSTOMER]", "[AD_GROUP_AD]"); AdGroupAd actualResponse = client.getAdGroupAd(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockAdGroupAdService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetAdGroupAdRequest actualRequest = (GetAdGroupAdRequest) actualRequests.get(0); Assert.assertEquals(resourceName, AdGroupAdName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getAdGroupAdExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockAdGroupAdService.addException(exception); try { AdGroupAdName resourceName = AdGroupAdName.of("[CUSTOMER]", "[AD_GROUP_AD]"); client.getAdGroupAd(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }