AdGroupServiceClient implements BackgroundResource { public final AdGroup getAdGroup(AdGroupName resourceName) { GetAdGroupRequest request = GetAdGroupRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getAdGroup(request); } protected  AdGroupServiceClient(AdGroupServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  AdGroupServiceClient(AdGroupServiceStub stub); static final AdGroupServiceClient create(); static final AdGroupServiceClient create(AdGroupServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final AdGroupServiceClient create(AdGroupServiceStub stub); final AdGroupServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") AdGroupServiceStub getStub(); final AdGroup getAdGroup(AdGroupName resourceName); final AdGroup getAdGroup(String resourceName); final AdGroup getAdGroup(GetAdGroupRequest request); final UnaryCallable<GetAdGroupRequest, AdGroup> getAdGroupCallable(); final MutateAdGroupsResponse mutateAdGroups(
      String customerId, List<AdGroupOperation> operations); final MutateAdGroupsResponse mutateAdGroups(MutateAdGroupsRequest request); final UnaryCallable<MutateAdGroupsRequest, MutateAdGroupsResponse> mutateAdGroupsCallable(); @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 getAdGroupTest() { com.google.ads.googleads.v5.services.AdGroupName resourceName2 = com.google.ads.googleads.v5.services.AdGroupName.of("[CUSTOMER]", "[AD_GROUP]"); long id = 3355L; com.google.ads.googleads.v5.services.AdGroupName name = com.google.ads.googleads.v5.services.AdGroupName.of("[CUSTOMER]", "[AD_GROUP]"); com.google.ads.googleads.v5.services.AdGroupName baseAdGroup = com.google.ads.googleads.v5.services.AdGroupName.of("[CUSTOMER]", "[AD_GROUP]"); String trackingUrlTemplate = "trackingUrlTemplate-1611329070"; CampaignName campaign = CampaignName.of("[CUSTOMER]", "[CAMPAIGN]"); long cpcBidMicros = 909381114L; long cpmBidMicros = 2094758992L; long targetCpaMicros = 733096280L; long cpvBidMicros = 933014521L; long targetCpmMicros = 1294208740L; double targetRoas = -2.08462819E8; long percentCpcBidMicros = 2098488628L; String finalUrlSuffix = "finalUrlSuffix-1825164662"; long effectiveTargetCpaMicros = 248222192L; double effectiveTargetRoas = -1.71721561E8; AdGroup expectedResponse = AdGroup.newBuilder() .setResourceName(resourceName2.toString()) .setId(id) .setName(name.toString()) .setBaseAdGroup(baseAdGroup.toString()) .setTrackingUrlTemplate(trackingUrlTemplate) .setCampaign(campaign.toString()) .setCpcBidMicros(cpcBidMicros) .setCpmBidMicros(cpmBidMicros) .setTargetCpaMicros(targetCpaMicros) .setCpvBidMicros(cpvBidMicros) .setTargetCpmMicros(targetCpmMicros) .setTargetRoas(targetRoas) .setPercentCpcBidMicros(percentCpcBidMicros) .setFinalUrlSuffix(finalUrlSuffix) .setEffectiveTargetCpaMicros(effectiveTargetCpaMicros) .setEffectiveTargetRoas(effectiveTargetRoas) .build(); mockAdGroupService.addResponse(expectedResponse); AdGroupName resourceName = AdGroupName.of("[CUSTOMER]", "[AD_GROUP]"); AdGroup actualResponse = client.getAdGroup(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockAdGroupService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetAdGroupRequest actualRequest = (GetAdGroupRequest) actualRequests.get(0); Assert.assertEquals(resourceName, AdGroupName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getAdGroupExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockAdGroupService.addException(exception); try { AdGroupName resourceName = AdGroupName.of("[CUSTOMER]", "[AD_GROUP]"); client.getAdGroup(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }