@Test
public void testDelayWithObservableDelayThrows() {

    PublishSubject<Integer> source = PublishSubject.create();
    final PublishSubject<Integer> delay = PublishSubject.create();
    Func1<Integer, Observable<Integer>> delayFunc = new Func1<Integer, Observable<Integer>>() {
        @Override
        public Observable<Integer> call(Integer t1) {
            return delay;
        }
    };
    @SuppressWarnings("unchecked")
    Observer<Object> o = mock(Observer.class);
    InOrder inOrder = inOrder(o);
    source.delay(delayFunc).subscribe(o);
    source.onNext(1);
    delay.onError(new OperationReduceTest.CustomException());
    inOrder.verify(o).onError(any(OperationReduceTest.CustomException.class));
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onNext(any());
    verify(o, never()).onCompleted();
}