use of io.reactivex.functions.Function in project RxJava by ReactiveX.
the class FlowableTimeoutWithSelectorTest method testTimeoutSelectorWithTimeoutFirstAndNoOtherFlowable.
@Test
public void testTimeoutSelectorWithTimeoutFirstAndNoOtherFlowable() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> timeout = PublishProcessor.create();
Function<Integer, Flowable<Integer>> timeoutFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return timeout;
}
};
Subscriber<Object> o = TestHelper.mockSubscriber();
source.timeout(PublishProcessor.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 FlowableTimeoutWithSelectorTest method testTimeoutSelectorNormal1.
@Test(timeout = 2000)
public void testTimeoutSelectorNormal1() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> timeout = PublishProcessor.create();
Function<Integer, Flowable<Integer>> timeoutFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return timeout;
}
};
Flowable<Integer> other = Flowable.fromIterable(Arrays.asList(100));
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
source.timeout(timeout, timeoutFunc, other).subscribe(o);
source.onNext(1);
source.onNext(2);
source.onNext(3);
timeout.onNext(1);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(2);
inOrder.verify(o).onNext(3);
inOrder.verify(o).onNext(100);
inOrder.verify(o).onComplete();
verify(o, never()).onError(any(Throwable.class));
}
use of io.reactivex.functions.Function in project RxJava by ReactiveX.
the class FlowableTimeoutWithSelectorTest method testTimeoutSelectorFirstFlowableThrows.
@Test
public void testTimeoutSelectorFirstFlowableThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> timeout = PublishProcessor.create();
Function<Integer, Flowable<Integer>> timeoutFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return timeout;
}
};
Flowable<Integer> other = Flowable.fromIterable(Arrays.asList(100));
Subscriber<Object> o = TestHelper.mockSubscriber();
source.timeout(Flowable.<Integer>error(new TestException()), timeoutFunc, other).subscribe(o);
verify(o).onError(any(TestException.class));
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
use of io.reactivex.functions.Function in project RxJava by ReactiveX.
the class FlowableTimeoutWithSelectorTest method testTimeoutSelectorWithFirstTimeoutFirstAndNoOtherFlowable.
@Test
public void testTimeoutSelectorWithFirstTimeoutFirstAndNoOtherFlowable() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> timeout = PublishProcessor.create();
Function<Integer, Flowable<Integer>> timeoutFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return PublishProcessor.create();
}
};
Subscriber<Object> o = TestHelper.mockSubscriber();
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 ObservableDebounceTest method debounceSelectorNormal1.
@Test
public void debounceSelectorNormal1() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> debouncer = PublishSubject.create();
Function<Integer, Observable<Integer>> debounceSel = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return debouncer;
}
};
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.debounce(debounceSel).subscribe(o);
source.onNext(1);
debouncer.onNext(1);
source.onNext(2);
source.onNext(3);
source.onNext(4);
debouncer.onNext(2);
source.onNext(5);
source.onComplete();
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(4);
inOrder.verify(o).onNext(5);
inOrder.verify(o).onComplete();
verify(o, never()).onError(any(Throwable.class));
}
Aggregations