AdServiceClient implements BackgroundResource { public final MutateAdsResponse mutateAds(String customerId, List<AdOperation> operations) { MutateAdsRequest request = MutateAdsRequest.newBuilder() .setCustomerId(customerId) .addAllOperations(operations) .build(); return mutateAds(request); } protected  AdServiceClient(AdServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  AdServiceClient(AdServiceStub stub); static final AdServiceClient create(); static final AdServiceClient create(AdServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final AdServiceClient create(AdServiceStub stub); final AdServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") AdServiceStub getStub(); final Ad getAd(AdName resourceName); final Ad getAd(String resourceName); final Ad getAd(GetAdRequest request); final UnaryCallable<GetAdRequest, Ad> getAdCallable(); final MutateAdsResponse mutateAds(String customerId, List<AdOperation> operations); final MutateAdsResponse mutateAds(MutateAdsRequest request); final UnaryCallable<MutateAdsRequest, MutateAdsResponse> mutateAdsCallable(); @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 mutateAdsTest() { MutateAdsResponse expectedResponse = MutateAdsResponse.newBuilder().build(); mockAdService.addResponse(expectedResponse); String customerId = "customerId-1772061412"; List<AdOperation> operations = new ArrayList<>(); MutateAdsResponse actualResponse = client.mutateAds(customerId, operations); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockAdService.getRequests(); Assert.assertEquals(1, actualRequests.size()); MutateAdsRequest actualRequest = (MutateAdsRequest) actualRequests.get(0); Assert.assertEquals(customerId, actualRequest.getCustomerId()); Assert.assertEquals(operations, actualRequest.getOperationsList()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void mutateAdsExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockAdService.addException(exception); try { String customerId = "customerId-1772061412"; List<AdOperation> operations = new ArrayList<>(); client.mutateAds(customerId, operations); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }