CampaignAssetServiceClient implements BackgroundResource { public final CampaignAsset getCampaignAsset(CampaignAssetName resourceName) { GetCampaignAssetRequest request = GetCampaignAssetRequest.newBuilder() .setResourceName(resourceName == null ? null : resourceName.toString()) .build(); return getCampaignAsset(request); } protected  CampaignAssetServiceClient(CampaignAssetServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  CampaignAssetServiceClient(CampaignAssetServiceStub stub); static final CampaignAssetServiceClient create(); static final CampaignAssetServiceClient create(CampaignAssetServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final CampaignAssetServiceClient create(CampaignAssetServiceStub stub); final CampaignAssetServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") CampaignAssetServiceStub getStub(); final CampaignAsset getCampaignAsset(CampaignAssetName resourceName); final CampaignAsset getCampaignAsset(String resourceName); final CampaignAsset getCampaignAsset(GetCampaignAssetRequest request); final UnaryCallable<GetCampaignAssetRequest, CampaignAsset> getCampaignAssetCallable(); final MutateCampaignAssetsResponse mutateCampaignAssets(
      String customerId, List<CampaignAssetOperation> operations); final MutateCampaignAssetsResponse mutateCampaignAssets(
      MutateCampaignAssetsRequest request); final UnaryCallable<MutateCampaignAssetsRequest, MutateCampaignAssetsResponse> mutateCampaignAssetsCallable(); @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 getCampaignAssetTest() { com.google.ads.googleads.v5.services.CampaignAssetName resourceName2 = com.google.ads.googleads.v5.services.CampaignAssetName.of( "[CUSTOMER]", "[CAMPAIGN_ASSET]"); CampaignName campaign = CampaignName.of("[CUSTOMER]", "[CAMPAIGN]"); AssetName asset = AssetName.of("[CUSTOMER]", "[ASSET]"); CampaignAsset expectedResponse = CampaignAsset.newBuilder() .setResourceName(resourceName2.toString()) .setCampaign(campaign.toString()) .setAsset(asset.toString()) .build(); mockCampaignAssetService.addResponse(expectedResponse); CampaignAssetName resourceName = CampaignAssetName.of("[CUSTOMER]", "[CAMPAIGN_ASSET]"); CampaignAsset actualResponse = client.getCampaignAsset(resourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockCampaignAssetService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetCampaignAssetRequest actualRequest = (GetCampaignAssetRequest) actualRequests.get(0); Assert.assertEquals(resourceName, CampaignAssetName.parse(actualRequest.getResourceName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getCampaignAssetExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockCampaignAssetService.addException(exception); try { CampaignAssetName resourceName = CampaignAssetName.of("[CUSTOMER]", "[CAMPAIGN_ASSET]"); client.getCampaignAsset(resourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }