RecommendationServiceClient implements BackgroundResource { public final ApplyRecommendationResponse applyRecommendation( String customerId, List<ApplyRecommendationOperation> operations) { ApplyRecommendationRequest request = ApplyRecommendationRequest.newBuilder() .setCustomerId(customerId) .addAllOperations(operations) .build(); return applyRecommendation(request); } protected  RecommendationServiceClient(RecommendationServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  RecommendationServiceClient(RecommendationServiceStub stub); static final RecommendationServiceClient create(); static final RecommendationServiceClient create(RecommendationServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final RecommendationServiceClient create(RecommendationServiceStub stub); final RecommendationServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") RecommendationServiceStub getStub(); final Recommendation getRecommendation(RecommendationName resourceName); final Recommendation getRecommendation(String resourceName); final Recommendation getRecommendation(GetRecommendationRequest request); final UnaryCallable<GetRecommendationRequest, Recommendation> getRecommendationCallable(); final ApplyRecommendationResponse applyRecommendation(
      String customerId, List<ApplyRecommendationOperation> operations); final ApplyRecommendationResponse applyRecommendation(ApplyRecommendationRequest request); final UnaryCallable<ApplyRecommendationRequest, ApplyRecommendationResponse> applyRecommendationCallable(); final DismissRecommendationResponse dismissRecommendation(
      String customerId,
      List<DismissRecommendationRequest.DismissRecommendationOperation> operations); final DismissRecommendationResponse dismissRecommendation(
      DismissRecommendationRequest request); final UnaryCallable<DismissRecommendationRequest, DismissRecommendationResponse> dismissRecommendationCallable(); @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 applyRecommendationTest() { ApplyRecommendationResponse expectedResponse = ApplyRecommendationResponse.newBuilder().build(); mockRecommendationService.addResponse(expectedResponse); String customerId = "customerId-1772061412"; List<ApplyRecommendationOperation> operations = new ArrayList<>(); ApplyRecommendationResponse actualResponse = client.applyRecommendation(customerId, operations); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockRecommendationService.getRequests(); Assert.assertEquals(1, actualRequests.size()); ApplyRecommendationRequest actualRequest = (ApplyRecommendationRequest) 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 applyRecommendationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockRecommendationService.addException(exception); try { String customerId = "customerId-1772061412"; List<ApplyRecommendationOperation> operations = new ArrayList<>(); client.applyRecommendation(customerId, operations); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }