AsyncContext implements EvalContext { @Override public final <T> Value<T> immediateValue(T t) { return new FuturePromise<>(this, executor, CompletableFuture.completedFuture(t)) .value(); } 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 public void valueContextIsCreatingContext() throws Exception { Value<String> value = context.immediateValue("hello"); assertThat(value.context(), is(context)); }
@Test public void immediateValueIsAvailable() throws Exception { AwaitValue<String> val = new AwaitValue<>(); context.immediateValue("hello").consume(val); assertThat(val.awaitAndGet(), is("hello")); }
@Test public void consumedValueIsAcceptedOnExecutorThread() throws Exception { String outerThread = Thread.currentThread().getName(); AwaitValue<String> val = new AwaitValue<>(); context.immediateValue("hello").consume(val); assertThat(val.acceptingThreadName(), not(is(outerThread))); }