### Question:
ImmediateFuture { public static <T> Future<T> newInstance(final T value) { return new Future<T>() { public boolean cancel(boolean mayInterruptIfRunning) { return false; } public boolean isCancelled() { return false; } public boolean isDone() { return true; } public T get() { return value; } public T get(long timeout, TimeUnit unit) { return value; } }; } private  ImmediateFuture(); static Future<T> newInstance(final T value); static Future<T> errorInstance(final Throwable error);  }### Answer:
@Test public void testGet() throws Exception { assertEquals("foo", ImmediateFuture.newInstance("foo").get()); }
@Test public void testGetNull() throws Exception { assertNull(ImmediateFuture.newInstance(null).get()); }
@Test public void testGetWithTimeout() throws Exception { assertEquals("foo", ImmediateFuture.newInstance("foo").get(1L, TimeUnit.MILLISECONDS)); }
@Test public void testCancel() { Future<String> stringFuture = ImmediateFuture.newInstance("foo"); assertFalse(stringFuture.cancel(true)); assertFalse(stringFuture.cancel(false)); assertFalse(stringFuture.isCancelled()); }
@Test public void testIsDone() { assertTrue(ImmediateFuture.newInstance("foo").isDone()); }