FutureUtils { public static <T> T block(CompletableFuture<? extends T> future) { try { return HttpUtils.waitFor(future); } catch (IOException e) { if (e.getCause() instanceof SW360ClientException) { throw (SW360ClientException) e.getCause(); } throw new SW360ClientException("Asynchronous call failed.", e); } } private  FutureUtils(); static T block(CompletableFuture<? extends T> future); static CompletableFuture<T> wrapFutureForConditionalFallback(CompletableFuture<T> future,
                                                                            Predicate<? super Throwable> condition,
                                                                            Supplier<? extends CompletableFuture<T>> fallback); static CompletableFuture<Optional<T>> optionalFuture(CompletableFuture<? extends T> future); static CompletableFuture<T> orFallback(CompletableFuture<Optional<T>> future,
                                                      Supplier<? extends CompletableFuture<T>> fallback); static CompletableFuture<Optional<T>> orRetry(CompletableFuture<Optional<T>> future,
                                                             Supplier<? extends CompletableFuture<Optional<T>>> retry); static boolean isFailedRequestWithStatus(Throwable exception, int statusCode); static CompletableFuture<T> failedFuture(Throwable ex); static CompletableFuture<Collection<T>> sequence(Collection<CompletableFuture<T>> futures,
                                                                Function<Throwable, Boolean> exceptionHandler); static CompletableFuture<T> wrapInFuture(Callable<? extends T> action, String errMsg);  }
@Test public void testBlockSuccessfulFuture() { CompletableFuture<Integer> future = CompletableFuture.completedFuture(RESULT); assertThat(FutureUtils.block(future)).isEqualTo(RESULT); }