CampaignBudgetServiceClient implements BackgroundResource { public final CampaignBudget getCampaignBudget(CampaignBudgetName resourceName) { GetCampaignBudgetRequest request = GetCampaignBudgetRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getCampaignBudget(request); } protected  CampaignBudgetServiceClient(CampaignBudgetServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  CampaignBudgetServiceClient(CampaignBudgetServiceStub stub); static final CampaignBudgetServiceClient create(); static final CampaignBudgetServiceClient create(CampaignBudgetServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final CampaignBudgetServiceClient create(CampaignBudgetServiceStub stub); final CampaignBudgetServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") CampaignBudgetServiceStub getStub(); final CampaignBudget getCampaignBudget(CampaignBudgetName resourceName); final CampaignBudget getCampaignBudget(String resourceName); final CampaignBudget getCampaignBudget(GetCampaignBudgetRequest request); final UnaryCallable<GetCampaignBudgetRequest, CampaignBudget> getCampaignBudgetCallable(); final MutateCampaignBudgetsResponse mutateCampaignBudgets(
      String customerId, List<CampaignBudgetOperation> operations); final MutateCampaignBudgetsResponse mutateCampaignBudgets(
      MutateCampaignBudgetsRequest request); final UnaryCallable<MutateCampaignBudgetsRequest, MutateCampaignBudgetsResponse> mutateCampaignBudgetsCallable(); @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 getCampaignBudgetTest() { com.google.ads.googleads.v5.services.CampaignBudgetName resourceName2 = com.google.ads.googleads.v5.services.CampaignBudgetName.of( "[CUSTOMER]", "[CAMPAIGN_BUDGET]"); long id = 3355L; com.google.ads.googleads.v5.services.CampaignBudgetName name = com.google.ads.googleads.v5.services.CampaignBudgetName.of( "[CUSTOMER]", "[CAMPAIGN_BUDGET]"); long amountMicros = 64599030L; long totalAmountMicros = 795564603L; boolean explicitlyShared = false; long referenceCount = 1214713627L; boolean hasRecommendedBudget = true; long recommendedBudgetAmountMicros = 332010528L; long recommendedBudgetEstimatedChangeWeeklyClicks = 1719888019L; long recommendedBudgetEstimatedChangeWeeklyCostMicros = 1264508103L; long recommendedBudgetEstimatedChangeWeeklyInteractions = 290892983L; long recommendedBudgetEstimatedChangeWeeklyViews = 1181313222L; CampaignBudget expectedResponse = CampaignBudget.newBuilder() .setResourceName(resourceName2.toString()) .setId(id) .setName(name.toString()) .setAmountMicros(amountMicros) .setTotalAmountMicros(totalAmountMicros) .setExplicitlyShared(explicitlyShared) .setReferenceCount(referenceCount) .setHasRecommendedBudget(hasRecommendedBudget) .setRecommendedBudgetAmountMicros(recommendedBudgetAmountMicros) .setRecommendedBudgetEstimatedChangeWeeklyClicks( recommendedBudgetEstimatedChangeWeeklyClicks) .setRecommendedBudgetEstimatedChangeWeeklyCostMicros( recommendedBudgetEstimatedChangeWeeklyCostMicros) .setRecommendedBudgetEstimatedChangeWeeklyInteractions( recommendedBudgetEstimatedChangeWeeklyInteractions) .setRecommendedBudgetEstimatedChangeWeeklyViews( recommendedBudgetEstimatedChangeWeeklyViews) .build(); mockCampaignBudgetService.addResponse(expectedResponse); CampaignBudgetName resourceName = CampaignBudgetName.of("[CUSTOMER]", "[CAMPAIGN_BUDGET]"); CampaignBudget actualResponse = client.getCampaignBudget(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockCampaignBudgetService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetCampaignBudgetRequest actualRequest = (GetCampaignBudgetRequest) actualRequests.get(0); Assert.assertEquals(resourceName, CampaignBudgetName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getCampaignBudgetExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockCampaignBudgetService.addException(exception); try { CampaignBudgetName resourceName = CampaignBudgetName.of("[CUSTOMER]", "[CAMPAIGN_BUDGET]"); client.getCampaignBudget(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }