@Test
public void testSingleOrDefaultWithPredicate() {

    Observable<Integer> observable = Observable.from(1, 2).singleOrDefault(
            4, new Func1<Integer, Boolean>() {
                @Override
                public Boolean call(Integer t1) {
                    return t1 % 2 == 0;
                }
            });
    @SuppressWarnings("unchecked")
    Observer<Integer> observer = (Observer<Integer>) mock(Observer.class);
    observable.subscribe(observer);
    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onNext(2);
    inOrder.verify(observer, times(1)).onCompleted();
    inOrder.verifyNoMoreInteractions();
}