Futures { public static <T> Future<T> withException(Exception exception){ return new FutureWithException<>(exception); } private  Futures(); static FutureWithTrigger<T> withTrigger(); static Future<T> withCallback(Consumer<Callback<T>> consumer); static Future<T> withValue(T value); static Future<T> withException(Exception exception); static Future<T> withCallable(Callable<T> callable); static Future<T> withCallable(Executor executor, Callable<T> callable); static Future<Set<T>> all(Future<T>... futures); static Future<Set<T>> all(Iterable<Future<T>> futures); static Future<T> any(Future<T>... futures); static Future<T> any(Iterable<Future<T>> futures);  }
@Test public void testWithException() { Exception exception = new DummyExceptions.DummyException1(); Future<Integer> future = Futures.withException(exception); try { future.await(); fail("Exception should have been thrown"); } catch (DummyExceptions.DummyException1 dex1){ assertEquals(exception, dex1); } catch (Exception ex){ fail("Should have got a DummyException1"); } }