@Test
public void cancel() {

  OperationsStub operationsStub = mock(OperationsStub.class);
  when(operationsStub.cancelOperationCallable())
      .thenReturn(
          new UnaryCallable<CancelOperationRequest, Empty>() {
            @Override
            public ApiFuture<Empty> futureCall(
                CancelOperationRequest 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.cancelOperationCallable().call("poseidon")).isNull();
}