use of io.reactivex.rxjava3.functions.BooleanSupplier in project RxJava by ReactiveX.
the class QueueDrainHelperTest method postCompleteEmpty.
@Test
public void postCompleteEmpty() {
TestSubscriber<Integer> ts = new TestSubscriber<>();
ArrayDeque<Integer> queue = new ArrayDeque<>();
AtomicLong state = new AtomicLong();
BooleanSupplier isCancelled = new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return false;
}
};
ts.onSubscribe(new BooleanSubscription());
QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
ts.assertResult();
}
use of io.reactivex.rxjava3.functions.BooleanSupplier in project RxJava by ReactiveX.
the class QueueDrainHelperTest method postCompleteCancelled.
@Test
public void postCompleteCancelled() {
final TestSubscriber<Integer> ts = new TestSubscriber<>();
ArrayDeque<Integer> queue = new ArrayDeque<>();
AtomicLong state = new AtomicLong();
BooleanSupplier isCancelled = new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return ts.isCancelled();
}
};
ts.onSubscribe(new BooleanSubscription());
queue.offer(1);
state.getAndIncrement();
ts.cancel();
QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
ts.assertEmpty();
}
use of io.reactivex.rxjava3.functions.BooleanSupplier in project RxJava by ReactiveX.
the class FlowableRetryTest method noCancelPreviousRetryUntil.
@Test
public void noCancelPreviousRetryUntil() {
final AtomicInteger counter = new AtomicInteger();
final AtomicInteger times = new AtomicInteger();
Flowable<Integer> source = Flowable.defer(new Supplier<Flowable<Integer>>() {
@Override
public Flowable<Integer> get() throws Exception {
if (times.getAndIncrement() < 4) {
return Flowable.error(new TestException());
}
return Flowable.just(1);
}
}).doOnCancel(new Action() {
@Override
public void run() throws Exception {
counter.getAndIncrement();
}
});
source.retryUntil(new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return false;
}
}).test().assertResult(1);
assertEquals(0, counter.get());
}
use of io.reactivex.rxjava3.functions.BooleanSupplier in project RxJava by ReactiveX.
the class ObservableRepeatTest method noCancelPreviousRepeatUntil.
@Test
public void noCancelPreviousRepeatUntil() {
final AtomicInteger counter = new AtomicInteger();
Observable<Integer> source = Observable.just(1).doOnDispose(new Action() {
@Override
public void run() throws Exception {
counter.getAndIncrement();
}
});
final AtomicInteger times = new AtomicInteger();
source.repeatUntil(new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return times.getAndIncrement() == 4;
}
}).test().assertResult(1, 1, 1, 1, 1);
assertEquals(0, counter.get());
}
use of io.reactivex.rxjava3.functions.BooleanSupplier in project RxJava by ReactiveX.
the class ObservableRetryTest method noCancelPreviousRetryUntil.
@Test
public void noCancelPreviousRetryUntil() {
final AtomicInteger counter = new AtomicInteger();
final AtomicInteger times = new AtomicInteger();
Observable<Integer> source = Observable.defer(new Supplier<ObservableSource<Integer>>() {
@Override
public ObservableSource<Integer> get() throws Exception {
if (times.getAndIncrement() < 4) {
return Observable.error(new TestException());
}
return Observable.just(1);
}
}).doOnDispose(new Action() {
@Override
public void run() throws Exception {
counter.getAndIncrement();
}
});
source.retryUntil(new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return false;
}
}).test().assertResult(1);
assertEquals(0, counter.get());
}
Aggregations