GrpcLongRunningClient implements LongRunningClient { @Override public UnaryCallable<String, Void> deleteOperationCallable() { return TranslatingUnaryCallable.create( operationsStub.deleteOperationCallable(), new ApiFunction<String, DeleteOperationRequest>() { @Override public DeleteOperationRequest apply(String request) { return DeleteOperationRequest.newBuilder().setName(request).build(); } }, new ApiFunction<Empty, Void>() { @Override public Void apply(Empty empty) { return null; } }); } GrpcLongRunningClient(OperationsStub operationsStub); @Override UnaryCallable<String, OperationSnapshot> getOperationCallable(); @Override UnaryCallable<String, Void> cancelOperationCallable(); @Override UnaryCallable<String, Void> deleteOperationCallable(); static GrpcLongRunningClient create(OperationsStub operationsStub);  }
@Test public void delete() { OperationsStub operationsStub = mock(OperationsStub.class); when(operationsStub.deleteOperationCallable()) .thenReturn( new UnaryCallable<DeleteOperationRequest, Empty>() { @Override public ApiFuture<Empty> futureCall( DeleteOperationRequest request, ApiCallContext context) { if (!request.getName().equals("poseidon")) { return ApiFutures.immediateFailedFuture( new IllegalStateException("Unexpected request: " + request)); } else { return ApiFutures.immediateFuture(Empty.getDefaultInstance()); } } }); LongRunningClient longRunningClient = new GrpcLongRunningClient(operationsStub); Truth.assertThat(longRunningClient.deleteOperationCallable().call("poseidon")).isNull(); }