@Test public void testIfCancelled_cancellationException() {

  AtomicReference<CancellationException> cancelled = new AtomicReference<>();
  CompletableFuture<String> future = new CompletableFuture<>();
  CancellationException exception = new CancellationException();
  future.completeExceptionally(exception);
  Utils.ifCancelled(future, cancelled::set);
  assertThat(cancelled.get()).isSameAs(exception);
}