AsyncContext implements EvalContext { @Override public <T> Promise<T> promise() { return new FuturePromise<>(this, executor, new CompletableFuture<>()); } private  AsyncContext(Executor executor); static EvalContext create(Executor executor); @Override Value<T> evaluateInternal(Task<T> task, EvalContext context); @Override final Value<T> value(Fn<T> t); @Override final Value<T> immediateValue(T t); @Override Promise<T> promise();  }
@Test(expected = IllegalStateException.class) public void promiseShouldOnlyAllowSetOnce() throws Exception { Promise<String> promise = context.promise(); promise.set("hello"); promise.set("nope"); }
@Test(expected = IllegalStateException.class) public void promiseShouldOnlyAllowFailOnce() throws Exception { Promise<String> promise = context.promise(); promise.fail(new Throwable()); promise.fail(new Throwable()); }