@Test
public void testToCompletableFuture() throws Exception {

  String result = "Result";
  ListeningExecutorService service =
      MoreExecutors.listeningDecorator(
          BigtableSessionSharedThreadPools.getInstance().getBatchThreadPool());
  ListenableFuture<String> listenableFuture =
      service.submit(
          new Callable<String>() {
            public String call() throws Exception {
              Thread.sleep(1000);
              return result;
            }
          });
  CompletableFuture<String> completableFuture = FutureUtils.toCompletableFuture(listenableFuture);
  assertFalse("Should be in progress", completableFuture.isDone());
  Throwable t = null;
  try {
    completableFuture.get(500, TimeUnit.MILLISECONDS);
  } catch (TimeoutException e) {
    t = e;
  }
  assertNotNull("TimeoutException is expected", t);
  assertEquals(result, completableFuture.get());
}