use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class CompletableDisposeOnTest method errorAfterCancel.
@Test
public void errorAfterCancel() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestScheduler scheduler = new TestScheduler();
PublishSubject<Integer> ps = PublishSubject.create();
TestObserver<Void> to = ps.ignoreElements().unsubscribeOn(scheduler).test();
to.dispose();
ps.onError(new TestException());
to.assertEmpty();
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.subjects.PublishSubject 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));
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableDelayTest method delayWithObservableNormal1.
@Test
public void delayWithObservableNormal1() {
PublishSubject<Integer> source = PublishSubject.create();
final List<PublishSubject<Integer>> delays = new ArrayList<>();
final int n = 10;
for (int i = 0; i < n; i++) {
PublishSubject<Integer> delay = PublishSubject.create();
delays.add(delay);
}
Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return delays.get(t1);
}
};
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.delay(delayFunc).subscribe(o);
for (int i = 0; i < n; i++) {
source.onNext(i);
delays.get(i).onNext(i);
inOrder.verify(o).onNext(i);
}
source.onComplete();
inOrder.verify(o).onComplete();
inOrder.verifyNoMoreInteractions();
verify(o, never()).onError(any(Throwable.class));
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableDelayTest method delayWithObservableReorder.
@Test
public void delayWithObservableReorder() {
int n = 3;
PublishSubject<Integer> source = PublishSubject.create();
final List<PublishSubject<Integer>> subjects = new ArrayList<>();
for (int i = 0; i < n; i++) {
subjects.add(PublishSubject.<Integer>create());
}
Observable<Integer> result = source.delay(new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return subjects.get(t1);
}
});
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
result.subscribe(o);
for (int i = 0; i < n; i++) {
source.onNext(i);
}
source.onComplete();
inOrder.verify(o, never()).onNext(anyInt());
inOrder.verify(o, never()).onComplete();
for (int i = n - 1; i >= 0; i--) {
subjects.get(i).onComplete();
inOrder.verify(o).onNext(i);
}
inOrder.verify(o).onComplete();
verify(o, never()).onError(any(Throwable.class));
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableDelayTest method delayWithObservableSingleSend1.
@Test
public void delayWithObservableSingleSend1() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> delay = PublishSubject.create();
Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return delay;
}
};
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.delay(delayFunc).subscribe(o);
source.onNext(1);
delay.onNext(1);
delay.onNext(2);
inOrder.verify(o).onNext(1);
inOrder.verifyNoMoreInteractions();
verify(o, never()).onError(any(Throwable.class));
}
Aggregations