CampaignServiceClient implements BackgroundResource { public final Campaign getCampaign(CampaignName resourceName) { GetCampaignRequest request = GetCampaignRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getCampaign(request); } protected  CampaignServiceClient(CampaignServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  CampaignServiceClient(CampaignServiceStub stub); static final CampaignServiceClient create(); static final CampaignServiceClient create(CampaignServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final CampaignServiceClient create(CampaignServiceStub stub); final CampaignServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") CampaignServiceStub getStub(); final Campaign getCampaign(CampaignName resourceName); final Campaign getCampaign(String resourceName); final Campaign getCampaign(GetCampaignRequest request); final UnaryCallable<GetCampaignRequest, Campaign> getCampaignCallable(); final MutateCampaignsResponse mutateCampaigns(
      String customerId, List<CampaignOperation> operations); final MutateCampaignsResponse mutateCampaigns(MutateCampaignsRequest request); final UnaryCallable<MutateCampaignsRequest, MutateCampaignsResponse> mutateCampaignsCallable(); @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 getCampaignTest() { com.google.ads.googleads.v5.services.CampaignName resourceName2 = com.google.ads.googleads.v5.services.CampaignName.of("[CUSTOMER]", "[CAMPAIGN]"); long id = 3355L; com.google.ads.googleads.v5.services.CampaignName name = com.google.ads.googleads.v5.services.CampaignName.of("[CUSTOMER]", "[CAMPAIGN]"); String trackingUrlTemplate = "trackingUrlTemplate-1611329070"; com.google.ads.googleads.v5.services.CampaignName baseCampaign = com.google.ads.googleads.v5.services.CampaignName.of("[CUSTOMER]", "[CAMPAIGN]"); CampaignBudgetName campaignBudget = CampaignBudgetName.of("[CUSTOMER]", "[CAMPAIGN_BUDGET]"); String startDate = "startDate-1573629589"; String endDate = "endDate1725067410"; String finalUrlSuffix = "finalUrlSuffix-1825164662"; double optimizationScore = -1.69982841E8; BiddingStrategyName biddingStrategy = BiddingStrategyName.of("[CUSTOMER]", "[BIDDING_STRATEGY]"); Campaign expectedResponse = Campaign.newBuilder() .setResourceName(resourceName2.toString()) .setId(id) .setName(name.toString()) .setTrackingUrlTemplate(trackingUrlTemplate) .setBaseCampaign(baseCampaign.toString()) .setCampaignBudget(campaignBudget.toString()) .setStartDate(startDate) .setEndDate(endDate) .setFinalUrlSuffix(finalUrlSuffix) .setOptimizationScore(optimizationScore) .setBiddingStrategy(biddingStrategy.toString()) .build(); mockCampaignService.addResponse(expectedResponse); CampaignName resourceName = CampaignName.of("[CUSTOMER]", "[CAMPAIGN]"); Campaign actualResponse = client.getCampaign(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockCampaignService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetCampaignRequest actualRequest = (GetCampaignRequest) actualRequests.get(0); Assert.assertEquals(resourceName, CampaignName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getCampaignExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockCampaignService.addException(exception); try { CampaignName resourceName = CampaignName.of("[CUSTOMER]", "[CAMPAIGN]"); client.getCampaign(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }