### Question:
FutureUtils { public static <T> void propagateResult( final CompletionStage<T> from, final CompletableFuture<T> to) { from.whenComplete( (value, error) -> { if (error != null) { to.completeExceptionally(error); } else { to.complete(value); } }); }  static CompletableFuture<T> exceptionallyCompose(
      final CompletableFuture<T> future,
      final Function<Throwable, CompletionStage<T>> errorHandler); static void propagateResult(
      final CompletionStage<T> from, final CompletableFuture<T> to); static void propagateResult(
      final Supplier<CompletableFuture<T>> from, final CompletableFuture<T> to); static void propagateCancellation(
      final CompletableFuture<?> from, final CompletableFuture<?> to);  }### Answer:
@Test public void shouldPropagateSuccessfulResult() { final CompletableFuture<String> input = new CompletableFuture<>(); final CompletableFuture<String> output = new CompletableFuture<>(); propagateResult(input, output); assertThat(output).isNotDone(); input.complete("Yay"); assertThat(output).isCompletedWithValue("Yay"); }
@Test public void shouldPropagateSuccessfulNullResult() { final CompletableFuture<String> input = new CompletableFuture<>(); final CompletableFuture<String> output = new CompletableFuture<>(); propagateResult(input, output); assertThat(output).isNotDone(); input.complete(null); assertThat(output).isCompletedWithValue(null); }
@Test public void shouldPropagateExceptionalResult() { final CompletableFuture<String> input = new CompletableFuture<>(); final CompletableFuture<String> output = new CompletableFuture<>(); propagateResult(input, output); assertThat(output).isNotDone(); input.completeExceptionally(ERROR); assertCompletedExceptionally(output, ERROR); }