### Question:
DefaultPromise implements Promise<V> { @Override public void addListener(final PromiseListener<V> listener) { if (listener == null) { throw new NullPointerException("FutureListener is null"); } boolean notifyNow = false; synchronized (lock) { if (!isDoing()) { notifyNow = true; } else { if (promiseListenerList == null) { promiseListenerList = new ArrayList<>(); } promiseListenerList.add(listener); } } if (notifyNow) { notifyListener(listener); } } DefaultPromise(); @Override boolean cancel(final boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override V get(); @Override V get(final long timeout); @Override boolean set(final V value); @Override boolean setFailure(final Throwable cause); @Override void addListener(final PromiseListener<V> listener); @Override Throwable getThrowable();  }### Answer:
@Test public void testAddListener() throws Exception { promise.addListener(new PromiseListener<String>() { @Override public void operationCompleted(final Promise<String> promise) { assertThat(promise.get()).isEqualTo("Done"); } @Override public void operationFailed(final Promise<String> promise) { } }); promise.set("Done"); }