use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class MaybeFlattenStreamAsFlowableTest method requestOneByOne.
@Test
public void requestOneByOne() {
TestSubscriber<Integer> ts = new TestSubscriber<>();
Maybe.just(1).flattenStreamAsFlowable(v -> Stream.of(1, 2, 3, 4, 5)).subscribe(new FlowableSubscriber<Integer>() {
Subscription upstream;
@Override
public void onSubscribe(@NonNull Subscription s) {
ts.onSubscribe(new BooleanSubscription());
upstream = s;
s.request(1);
}
@Override
public void onNext(Integer t) {
ts.onNext(t);
upstream.request(1);
}
@Override
public void onError(Throwable t) {
ts.onError(t);
}
@Override
public void onComplete() {
ts.onComplete();
}
});
ts.assertResult(1, 2, 3, 4, 5);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class SingleFlattenStreamAsFlowableTest method requestOneByOne.
@Test
public void requestOneByOne() {
TestSubscriber<Integer> ts = new TestSubscriber<>();
Single.just(1).flattenStreamAsFlowable(v -> Stream.of(1, 2, 3, 4, 5)).subscribe(new FlowableSubscriber<Integer>() {
Subscription upstream;
@Override
public void onSubscribe(@NonNull Subscription s) {
ts.onSubscribe(new BooleanSubscription());
upstream = s;
s.request(1);
}
@Override
public void onNext(Integer t) {
ts.onNext(t);
upstream.request(1);
}
@Override
public void onError(Throwable t) {
ts.onError(t);
}
@Override
public void onComplete() {
ts.onComplete();
}
});
ts.assertResult(1, 2, 3, 4, 5);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableCollectWithCollectorTest method collectorAccumulatorDropSignals.
@Test
public void collectorAccumulatorDropSignals() throws Throwable {
TestHelper.withErrorTracking(errors -> {
Flowable<Integer> source = new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
s.onNext(1);
s.onNext(2);
s.onError(new IOException());
s.onComplete();
}
};
source.collect(new Collector<Integer, Integer, Integer>() {
@Override
public Supplier<Integer> supplier() {
return () -> 1;
}
@Override
public BiConsumer<Integer, Integer> accumulator() {
return (a, b) -> {
throw new TestException();
};
}
@Override
public BinaryOperator<Integer> combiner() {
return (a, b) -> a + b;
}
@Override
public Function<Integer, Integer> finisher() {
return a -> a;
}
@Override
public Set<Characteristics> characteristics() {
return Collections.emptySet();
}
}).test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
});
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class NotificationLiteTest method subscriptionNotification.
@Test
public void subscriptionNotification() {
Object o = NotificationLite.subscription(new BooleanSubscription());
assertEquals("NotificationLite.Subscription[BooleanSubscription(cancelled=false)]", o.toString());
assertFalse(NotificationLite.isError(o));
assertFalse(NotificationLite.isComplete(o));
assertFalse(NotificationLite.isDisposable(o));
assertTrue(NotificationLite.isSubscription(o));
assertNotNull(NotificationLite.getSubscription(o));
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableWindowWithStartEndFlowableTest method windowOpenMainCompletes.
@Test
public void windowOpenMainCompletes() {
AtomicReference<Subscriber<? super Integer>> ref1 = new AtomicReference<>();
PublishProcessor<Object> pp = PublishProcessor.create();
Flowable<Integer> f1 = Flowable.<Integer>unsafeCreate(ref1::set);
AtomicInteger counter = new AtomicInteger();
TestSubscriber<Flowable<Object>> ts = pp.window(f1, v -> Flowable.never()).doOnNext(w -> {
if (counter.getAndIncrement() == 0) {
ref1.get().onNext(2);
pp.onNext(1);
pp.onComplete();
}
w.test();
}).test();
ref1.get().onSubscribe(new BooleanSubscription());
ref1.get().onNext(1);
ts.assertComplete();
}
Aggregations