@Test
public void testTakeWhile2() {

    Observable<String> w = Observable.from("one", "two", "three");
    Observable<String> take = Observable.create(takeWhileWithIndex(w, new Func2<String, Integer, Boolean>() {
        @Override
        public Boolean call(String input, Integer index) {
            return index < 2;
        }
    }));
    @SuppressWarnings("unchecked")
    Observer<String> observer = mock(Observer.class);
    take.subscribe(observer);
    verify(observer, times(1)).onNext("one");
    verify(observer, times(1)).onNext("two");
    verify(observer, never()).onNext("three");
    verify(observer, never()).onError(any(Throwable.class));
    verify(observer, times(1)).onCompleted();
}