use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableMergeWithMaybeTest method cancelOtherOnMainError.
@Test
public void cancelOtherOnMainError() {
PublishSubject<Integer> ps = PublishSubject.create();
MaybeSubject<Integer> ms = MaybeSubject.create();
TestObserver<Integer> to = ps.mergeWith(ms).test();
assertTrue(ps.hasObservers());
assertTrue(ms.hasObservers());
ps.onError(new TestException());
to.assertFailure(TestException.class);
assertFalse("main has observers!", ps.hasObservers());
assertFalse("other has observers", ms.hasObservers());
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableMergeWithCompletableTest method cancelOtherOnMainError.
@Test
public void cancelOtherOnMainError() {
PublishSubject<Integer> ps = PublishSubject.create();
CompletableSubject cs = CompletableSubject.create();
TestObserver<Integer> to = ps.mergeWith(cs).test();
assertTrue(ps.hasObservers());
assertTrue(cs.hasObservers());
ps.onError(new TestException());
to.assertFailure(TestException.class);
assertFalse("main has observers!", ps.hasObservers());
assertFalse("other has observers", cs.hasObservers());
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableMergeWithCompletableTest method cancelMainOnOtherError.
@Test
public void cancelMainOnOtherError() {
PublishSubject<Integer> ps = PublishSubject.create();
CompletableSubject cs = CompletableSubject.create();
TestObserver<Integer> to = ps.mergeWith(cs).test();
assertTrue(ps.hasObservers());
assertTrue(cs.hasObservers());
cs.onError(new TestException());
to.assertFailure(TestException.class);
assertFalse("main has observers!", ps.hasObservers());
assertFalse("other has observers", cs.hasObservers());
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableHideTest method hidingError.
@Test
public void hidingError() {
PublishSubject<Integer> src = PublishSubject.create();
Observable<Integer> dst = src.hide();
assertFalse(dst instanceof PublishSubject);
Observer<Object> o = TestHelper.mockObserver();
dst.subscribe(o);
src.onError(new TestException());
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
verify(o).onError(any(TestException.class));
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableThrottleLastTests method throttle.
@Test
public void throttle() {
Observer<Integer> observer = TestHelper.mockObserver();
TestScheduler s = new TestScheduler();
PublishSubject<Integer> o = PublishSubject.create();
o.throttleLast(500, TimeUnit.MILLISECONDS, s).subscribe(observer);
// send events with simulated time increments
s.advanceTimeTo(0, TimeUnit.MILLISECONDS);
// skip
o.onNext(1);
// deliver
o.onNext(2);
s.advanceTimeTo(501, TimeUnit.MILLISECONDS);
// skip
o.onNext(3);
s.advanceTimeTo(600, TimeUnit.MILLISECONDS);
// skip
o.onNext(4);
s.advanceTimeTo(700, TimeUnit.MILLISECONDS);
// skip
o.onNext(5);
// deliver
o.onNext(6);
s.advanceTimeTo(1001, TimeUnit.MILLISECONDS);
// deliver
o.onNext(7);
s.advanceTimeTo(1501, TimeUnit.MILLISECONDS);
o.onComplete();
InOrder inOrder = inOrder(observer);
inOrder.verify(observer).onNext(2);
inOrder.verify(observer).onNext(6);
inOrder.verify(observer).onNext(7);
inOrder.verify(observer).onComplete();
inOrder.verifyNoMoreInteractions();
}
Aggregations