@Test
public void testListenerFailure() throws Exception {

    @SuppressWarnings("unchecked")
    Promise<Void> p1 = mock(Promise.class);
    @SuppressWarnings("unchecked")
    Promise<Void> p2 = mock(Promise.class);
    @SuppressWarnings("unchecked")
    PromiseNotifier<Void, Future<Void>> notifier =
            new PromiseNotifier<Void, Future<Void>>(p1, p2);
    @SuppressWarnings("unchecked")
    Future<Void> future = mock(Future.class);
    Throwable t = mock(Throwable.class);
    when(future.isSuccess()).thenReturn(false);
    when(future.isCancelled()).thenReturn(false);
    when(future.cause()).thenReturn(t);
    when(p1.tryFailure(t)).thenReturn(true);
    when(p2.tryFailure(t)).thenReturn(true);
    notifier.operationComplete(future);
    verify(p1).tryFailure(t);
    verify(p2).tryFailure(t);
}