CampaignCriterionServiceClient implements BackgroundResource { public final CampaignCriterion getCampaignCriterion(CampaignCriterionName resourceName) { GetCampaignCriterionRequest request = GetCampaignCriterionRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getCampaignCriterion(request); } protected  CampaignCriterionServiceClient(CampaignCriterionServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  CampaignCriterionServiceClient(CampaignCriterionServiceStub stub); static final CampaignCriterionServiceClient create(); static final CampaignCriterionServiceClient create(
      CampaignCriterionServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final CampaignCriterionServiceClient create(CampaignCriterionServiceStub stub); final CampaignCriterionServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") CampaignCriterionServiceStub getStub(); final CampaignCriterion getCampaignCriterion(CampaignCriterionName resourceName); final CampaignCriterion getCampaignCriterion(String resourceName); final CampaignCriterion getCampaignCriterion(GetCampaignCriterionRequest request); final UnaryCallable<GetCampaignCriterionRequest, CampaignCriterion> getCampaignCriterionCallable(); final MutateCampaignCriteriaResponse mutateCampaignCriteria(
      String customerId, List<CampaignCriterionOperation> operations); final MutateCampaignCriteriaResponse mutateCampaignCriteria(
      MutateCampaignCriteriaRequest request); final UnaryCallable<MutateCampaignCriteriaRequest, MutateCampaignCriteriaResponse> mutateCampaignCriteriaCallable(); @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 getCampaignCriterionTest() { com.google.ads.googleads.v5.services.CampaignCriterionName resourceName2 = com.google.ads.googleads.v5.services.CampaignCriterionName.of( "[CUSTOMER]", "[CAMPAIGN_CRITERION]"); CampaignName campaign = CampaignName.of("[CUSTOMER]", "[CAMPAIGN]"); long criterionId = 326773895L; float bidModifier = 1.36236335E8F; boolean negative = false; CampaignCriterion expectedResponse = CampaignCriterion.newBuilder() .setResourceName(resourceName2.toString()) .setCampaign(campaign.toString()) .setCriterionId(criterionId) .setBidModifier(bidModifier) .setNegative(negative) .build(); mockCampaignCriterionService.addResponse(expectedResponse); CampaignCriterionName resourceName = CampaignCriterionName.of("[CUSTOMER]", "[CAMPAIGN_CRITERION]"); CampaignCriterion actualResponse = client.getCampaignCriterion(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockCampaignCriterionService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetCampaignCriterionRequest actualRequest = (GetCampaignCriterionRequest) actualRequests.get(0); Assert.assertEquals(resourceName, CampaignCriterionName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getCampaignCriterionExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockCampaignCriterionService.addException(exception); try { CampaignCriterionName resourceName = CampaignCriterionName.of("[CUSTOMER]", "[CAMPAIGN_CRITERION]"); client.getCampaignCriterion(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }