use of io.reactivex.functions.Function in project RxJava by ReactiveX.
the class ObservableTimeoutWithSelectorTest method testTimeoutSelectorSubsequentObservableThrows.
@Test
public void testTimeoutSelectorSubsequentObservableThrows() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> timeout = PublishSubject.create();
Function<Integer, Observable<Integer>> timeoutFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return Observable.<Integer>error(new TestException());
}
};
Observable<Integer> other = Observable.fromIterable(Arrays.asList(100));
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.timeout(timeout, timeoutFunc, other).subscribe(o);
source.onNext(1);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onError(any(TestException.class));
verify(o, never()).onComplete();
}
use of io.reactivex.functions.Function in project RxJava by ReactiveX.
the class ObservableTimeoutWithSelectorTest method testTimeoutSelectorWithTimeoutFirstAndNoOtherObservable.
@Test
public void testTimeoutSelectorWithTimeoutFirstAndNoOtherObservable() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> timeout = PublishSubject.create();
Function<Integer, Observable<Integer>> timeoutFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return timeout;
}
};
Observer<Object> o = TestHelper.mockObserver();
source.timeout(PublishSubject.create(), timeoutFunc).subscribe(o);
source.onNext(1);
timeout.onNext(1);
InOrder inOrder = inOrder(o);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onError(isA(TimeoutException.class));
inOrder.verifyNoMoreInteractions();
}
use of io.reactivex.functions.Function in project RxJava by ReactiveX.
the class ObservableTimeoutWithSelectorTest method testTimeoutSelectorSubsequentThrows.
@Test
public void testTimeoutSelectorSubsequentThrows() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> timeout = PublishSubject.create();
Function<Integer, Observable<Integer>> timeoutFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
throw new TestException();
}
};
Observable<Integer> other = Observable.fromIterable(Arrays.asList(100));
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.timeout(timeout, timeoutFunc, other).subscribe(o);
source.onNext(1);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onError(any(TestException.class));
verify(o, never()).onComplete();
}
use of io.reactivex.functions.Function in project RxJava by ReactiveX.
the class ObservableTimeoutWithSelectorTest method testTimeoutSelectorWithFirstTimeoutFirstAndNoOtherObservable.
@Test
public void testTimeoutSelectorWithFirstTimeoutFirstAndNoOtherObservable() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> timeout = PublishSubject.create();
Function<Integer, Observable<Integer>> timeoutFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return PublishSubject.create();
}
};
Observer<Object> o = TestHelper.mockObserver();
source.timeout(timeout, timeoutFunc).subscribe(o);
timeout.onNext(1);
InOrder inOrder = inOrder(o);
inOrder.verify(o).onError(isA(TimeoutException.class));
inOrder.verifyNoMoreInteractions();
}
use of io.reactivex.functions.Function in project RxJava by ReactiveX.
the class ObservableTimeoutWithSelectorTest method testTimeoutSelectorFirstObservableThrows.
@Test
public void testTimeoutSelectorFirstObservableThrows() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> timeout = PublishSubject.create();
Function<Integer, Observable<Integer>> timeoutFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return timeout;
}
};
Observable<Integer> other = Observable.fromIterable(Arrays.asList(100));
Observer<Object> o = TestHelper.mockObserver();
source.timeout(Observable.<Integer>error(new TestException()), timeoutFunc, other).subscribe(o);
verify(o).onError(any(TestException.class));
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
Aggregations