use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class FlowableDelayTest method delayWithFlowableDelayFunctionThrows.
@Test
public void delayWithFlowableDelayFunctionThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
throw new TestException();
}
};
Subscriber<Object> subscriber = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(subscriber);
source.delay(delayFunc).subscribe(subscriber);
source.onNext(1);
inOrder.verify(subscriber).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(subscriber, never()).onNext(any());
verify(subscriber, never()).onComplete();
}
use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class FlowableDebounceTest method debounceSelectorNormal1.
@Test
public void debounceSelectorNormal1() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> debouncer = PublishProcessor.create();
Function<Integer, Flowable<Integer>> debounceSel = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return debouncer;
}
};
Subscriber<Object> subscriber = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(subscriber);
source.debounce(debounceSel).subscribe(subscriber);
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(subscriber).onNext(1);
inOrder.verify(subscriber).onNext(4);
inOrder.verify(subscriber).onNext(5);
inOrder.verify(subscriber).onComplete();
verify(subscriber, never()).onError(any(Throwable.class));
}
use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class FlowableDelayTest method delayWithFlowableDelayThrows.
@Test
public void delayWithFlowableDelayThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> delay = PublishProcessor.create();
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return delay;
}
};
Subscriber<Object> subscriber = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(subscriber);
source.delay(delayFunc).subscribe(subscriber);
source.onNext(1);
delay.onError(new TestException());
inOrder.verify(subscriber).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(subscriber, never()).onNext(any());
verify(subscriber, never()).onComplete();
}
use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class FlowableDelayTest method delayWithFlowableSubscriptionFunctionThrows.
@Test
public void delayWithFlowableSubscriptionFunctionThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> delay = PublishProcessor.create();
Supplier<Flowable<Integer>> subFunc = new Supplier<Flowable<Integer>>() {
@Override
public Flowable<Integer> get() {
throw new TestException();
}
};
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return delay;
}
};
Subscriber<Object> subscriber = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(subscriber);
source.delay(Flowable.defer(subFunc), delayFunc).subscribe(subscriber);
source.onNext(1);
delay.onNext(1);
source.onNext(2);
inOrder.verify(subscriber).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(subscriber, never()).onNext(any());
verify(subscriber, never()).onComplete();
}
use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class ObservableRetryTest method repeatFloodNoSubscriptionError.
@Test
public void repeatFloodNoSubscriptionError() {
List<Throwable> errors = TestHelper.trackPluginErrors();
final TestException error = new TestException();
try {
final PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> signaller = PublishSubject.create();
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
TestObserver<Integer> to = source.take(1).map(new Function<Integer, Integer>() {
@Override
public Integer apply(Integer v) throws Exception {
throw error;
}
}).retryWhen(new Function<Observable<Throwable>, ObservableSource<Integer>>() {
@Override
public ObservableSource<Integer> apply(Observable<Throwable> v) throws Exception {
return signaller;
}
}).test();
Runnable r1 = new Runnable() {
@Override
public void run() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
source.onNext(1);
}
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
signaller.onNext(1);
}
}
};
TestHelper.race(r1, r2);
to.dispose();
}
if (!errors.isEmpty()) {
for (Throwable e : errors) {
e.printStackTrace();
}
fail(errors + "");
}
} finally {
RxJavaPlugins.reset();
}
}
Aggregations