use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableZipIterableTest method zipIterableHasNextThrows.
@Test
public void zipIterableHasNextThrows() {
PublishSubject<String> r1 = PublishSubject.create();
/* define an Observer to receive aggregated events */
Observer<String> o = TestHelper.mockObserver();
InOrder io = inOrder(o);
Iterable<String> r2 = new Iterable<String>() {
@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
int count;
@Override
public boolean hasNext() {
if (count == 0) {
return true;
}
throw new TestException();
}
@Override
public String next() {
count++;
return "1";
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
};
r1.zipWith(r2, zipr2).subscribe(o);
r1.onNext("one-");
r1.onError(new TestException());
io.verify(o).onNext("one-1");
io.verify(o).onError(any(TestException.class));
verify(o, never()).onComplete();
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableZipIterableTest method zipIterableFirstThrows.
@Test
public void zipIterableFirstThrows() {
PublishSubject<String> r1 = PublishSubject.create();
/* define an Observer to receive aggregated events */
Observer<String> o = TestHelper.mockObserver();
InOrder io = inOrder(o);
Iterable<String> r2 = Arrays.asList("1", "2", "3");
r1.zipWith(r2, zipr2).subscribe(o);
r1.onNext("one-");
r1.onNext("two-");
r1.onError(new TestException());
io.verify(o).onNext("one-1");
io.verify(o).onNext("two-2");
io.verify(o).onError(any(TestException.class));
verify(o, never()).onComplete();
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableZipIterableTest method zipIterableIteratorThrows.
@Test
public void zipIterableIteratorThrows() {
PublishSubject<String> r1 = PublishSubject.create();
/* define an Observer to receive aggregated events */
Observer<String> o = TestHelper.mockObserver();
InOrder io = inOrder(o);
Iterable<String> r2 = new Iterable<String>() {
@Override
public Iterator<String> iterator() {
throw new TestException();
}
};
r1.zipWith(r2, zipr2).subscribe(o);
r1.onNext("one-");
r1.onNext("two-");
r1.onError(new TestException());
io.verify(o).onError(any(TestException.class));
verify(o, never()).onComplete();
verify(o, never()).onNext(any(String.class));
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableThrottleLatestTest method normal.
@Test
public void normal() {
TestScheduler sch = new TestScheduler();
PublishSubject<Integer> ps = PublishSubject.create();
TestObserver<Integer> to = ps.throttleLatest(1, TimeUnit.SECONDS, sch).test();
ps.onNext(1);
to.assertValuesOnly(1);
ps.onNext(2);
to.assertValuesOnly(1);
ps.onNext(3);
to.assertValuesOnly(1);
sch.advanceTimeBy(1, TimeUnit.SECONDS);
to.assertValuesOnly(1, 3);
ps.onNext(4);
to.assertValuesOnly(1, 3);
ps.onNext(5);
sch.advanceTimeBy(1, TimeUnit.SECONDS);
to.assertValuesOnly(1, 3, 5);
sch.advanceTimeBy(1, TimeUnit.SECONDS);
to.assertValuesOnly(1, 3, 5);
ps.onNext(6);
to.assertValuesOnly(1, 3, 5, 6);
ps.onNext(7);
ps.onComplete();
to.assertResult(1, 3, 5, 6);
sch.advanceTimeBy(1, TimeUnit.SECONDS);
to.assertResult(1, 3, 5, 6);
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableTakeTimedTest method takeTimedErrorBeforeTime.
@Test
public void takeTimedErrorBeforeTime() {
TestScheduler scheduler = new TestScheduler();
PublishSubject<Integer> source = PublishSubject.create();
Observable<Integer> result = source.take(1, TimeUnit.SECONDS, scheduler);
Observer<Object> o = TestHelper.mockObserver();
result.subscribe(o);
source.onNext(1);
source.onNext(2);
source.onNext(3);
source.onError(new TestException());
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
source.onNext(4);
InOrder inOrder = inOrder(o);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(2);
inOrder.verify(o).onNext(3);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onComplete();
verify(o, never()).onNext(4);
}
Aggregations