SyncContext implements EvalContext { @Override public <T> Promise<T> promise() { return new FuturePromise<>(this, new SameThreadExecutor(), new CompletableFuture<>()); } private  SyncContext(); static EvalContext create(); @Override Value<T> value(Fn<T> value); @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()); }