@Test public void testFailedFuture() throws Exception { CompletableFuture<Object> asyncFuture = FutureUtils.failedFuture(new IllegalStateException("Test failed feature")); assertTrue("future should be complete", asyncFuture.isDone()); assertTrue("Should complete with exception", asyncFuture.isCompletedExceptionally()); thrown.expect(ExecutionException.class); thrown.expectCause(IsInstanceOf.<Throwable>instanceOf(IllegalStateException.class)); thrown.expectMessage(containsString("Test failed feature")); asyncFuture.get(); }
public static <T> CompletableFuture<T> failedFuture(Throwable error) { CompletableFuture<T> future = new CompletableFuture<>(); future.completeExceptionally(error); return future; }
FutureUtils { public static <T> CompletableFuture<T> failedFuture(Throwable error) { CompletableFuture<T> future = new CompletableFuture<>(); future.completeExceptionally(error); return future; } }
FutureUtils { public static <T> CompletableFuture<T> failedFuture(Throwable error) { CompletableFuture<T> future = new CompletableFuture<>(); future.completeExceptionally(error); return future; }  }
FutureUtils { public static <T> CompletableFuture<T> failedFuture(Throwable error) { CompletableFuture<T> future = new CompletableFuture<>(); future.completeExceptionally(error); return future; }  static CompletableFuture<T> toCompletableFuture(ApiFuture<T> apiFuture); static CompletableFuture<T> toCompletableFuture(ListenableFuture<T> listenableFuture); static CompletableFuture<T> failedFuture(Throwable error); }
FutureUtils { public static <T> CompletableFuture<T> failedFuture(Throwable error) { CompletableFuture<T> future = new CompletableFuture<>(); future.completeExceptionally(error); return future; }  static CompletableFuture<T> toCompletableFuture(ApiFuture<T> apiFuture); static CompletableFuture<T> toCompletableFuture(ListenableFuture<T> listenableFuture); static CompletableFuture<T> failedFuture(Throwable error); static final ExecutorService DIRECT_EXECUTOR; }