OperationSkipWhile { public static <T> OnSubscribeFunc<T> skipWhile(Observable<? extends T> source, final Func1<? super T, Boolean> predicate) { return new SkipWhile<T>(source, new Func2<T, Integer, Boolean>() { @Override public Boolean call(T value, Integer index) { return predicate.call(value); } }); }  static OnSubscribeFunc<T> skipWhileWithIndex(Observable<? extends T> source, Func2<? super T, Integer, Boolean> predicate); static OnSubscribeFunc<T> skipWhile(Observable<? extends T> source, final Func1<? super T, Boolean> predicate);  }
@Test public void testSkipEmpty() { Observable<Integer> src = Observable.empty(); Observable.create(skipWhile(src, LESS_THAN_FIVE)).subscribe(w); verify(w, never()).onNext(anyInt()); verify(w, never()).onError(any(Throwable.class)); verify(w, times(1)).onCompleted(); }
@Test public void testSkipEverything() { Observable<Integer> src = Observable.from(1, 2, 3, 4, 3, 2, 1); Observable.create(skipWhile(src, LESS_THAN_FIVE)).subscribe(w); verify(w, never()).onNext(anyInt()); verify(w, never()).onError(any(Throwable.class)); verify(w, times(1)).onCompleted(); }
@Test public void testSkipNothing() { Observable<Integer> src = Observable.from(5, 3, 1); Observable.create(skipWhile(src, LESS_THAN_FIVE)).subscribe(w); InOrder inOrder = inOrder(w); inOrder.verify(w, times(1)).onNext(5); inOrder.verify(w, times(1)).onNext(3); inOrder.verify(w, times(1)).onNext(1); inOrder.verify(w, times(1)).onCompleted(); inOrder.verify(w, never()).onError(any(Throwable.class)); }
@Test public void testSkipSome() { Observable<Integer> src = Observable.from(1, 2, 3, 4, 5, 3, 1, 5); Observable.create(skipWhile(src, LESS_THAN_FIVE)).subscribe(w); InOrder inOrder = inOrder(w); inOrder.verify(w, times(1)).onNext(5); inOrder.verify(w, times(1)).onNext(3); inOrder.verify(w, times(1)).onNext(1); inOrder.verify(w, times(1)).onNext(5); inOrder.verify(w, times(1)).onCompleted(); inOrder.verify(w, never()).onError(any(Throwable.class)); }
@Test public void testSkipError() { Observable<Integer> src = Observable.from(1, 2, 42, 5, 3, 1); Observable.create(skipWhile(src, LESS_THAN_FIVE)).subscribe(w); InOrder inOrder = inOrder(w); inOrder.verify(w, never()).onNext(anyInt()); inOrder.verify(w, never()).onCompleted(); inOrder.verify(w, times(1)).onError(any(RuntimeException.class)); }