GoogleAdsServiceClient implements BackgroundResource { public final MutateGoogleAdsResponse mutate( String customerId, List<MutateOperation> mutateOperations) { MutateGoogleAdsRequest request = MutateGoogleAdsRequest.newBuilder() .setCustomerId(customerId) .addAllMutateOperations(mutateOperations) .build(); return mutate(request); } protected  GoogleAdsServiceClient(GoogleAdsServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  GoogleAdsServiceClient(GoogleAdsServiceStub stub); static final GoogleAdsServiceClient create(); static final GoogleAdsServiceClient create(GoogleAdsServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final GoogleAdsServiceClient create(GoogleAdsServiceStub stub); final GoogleAdsServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") GoogleAdsServiceStub getStub(); final SearchPagedResponse search(String customerId, String query); final SearchPagedResponse search(SearchGoogleAdsRequest request); final UnaryCallable<SearchGoogleAdsRequest, SearchPagedResponse> searchPagedCallable(); final UnaryCallable<SearchGoogleAdsRequest, SearchGoogleAdsResponse> searchCallable(); final ServerStreamingCallable<SearchGoogleAdsStreamRequest, SearchGoogleAdsStreamResponse> searchStreamCallable(); final MutateGoogleAdsResponse mutate(
      String customerId, List<MutateOperation> mutateOperations); final MutateGoogleAdsResponse mutate(MutateGoogleAdsRequest request); final UnaryCallable<MutateGoogleAdsRequest, MutateGoogleAdsResponse> mutateCallable(); @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 mutateTest() { MutateGoogleAdsResponse expectedResponse = MutateGoogleAdsResponse.newBuilder().build(); mockGoogleAdsService.addResponse(expectedResponse); String customerId = "customerId-1772061412"; List<MutateOperation> mutateOperations = new ArrayList<>(); MutateGoogleAdsResponse actualResponse = client.mutate(customerId, mutateOperations); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockGoogleAdsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); MutateGoogleAdsRequest actualRequest = (MutateGoogleAdsRequest) actualRequests.get(0); Assert.assertEquals(customerId, actualRequest.getCustomerId()); Assert.assertEquals(mutateOperations, actualRequest.getMutateOperationsList()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void mutateExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockGoogleAdsService.addException(exception); try { String customerId = "customerId-1772061412"; List<MutateOperation> mutateOperations = new ArrayList<>(); client.mutate(customerId, mutateOperations); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }