@Test(expected = NullPointerException.class) public void fromObservableNull() { Completable.fromObservable(null); }
@Test(expected = NullPointerException.class) public void fromObservableNull() { Completable.fromObservable(null); }
/** * Returns a Completable that repeatedly subscribes to this Completable until cancelled. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code repeat} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @return the new Completable instance */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable repeat() { return fromObservable(toObservable().repeat()); }
/** * Returns a Completable that retries this Completable as long as it emits an onError event. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code retry} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @return the new Completable instance */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable retry() { return fromObservable(toObservable().retry()); }
/** * Returns a Completable that retries this Completable as long as it emits an onError event. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code retry} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @return the new Completable instance */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable retry() { return fromObservable(toObservable().retry()); }
/** * Returns a Completable that repeatedly subscribes to this Completable until cancelled. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code repeat} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @return the new Completable instance */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable repeat() { return fromObservable(toObservable().repeat()); }
/** * Returns a Completable that when this Completable emits an error, retries at most the given * number of times before giving up and emitting the last error. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code retry} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param times the number of times the returned Completable should retry this Completable * @return the new Completable instance * @throws IllegalArgumentException if times is negative */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable retry(long times) { return fromObservable(toObservable().retry(times)); }
/** * Returns a Completable that repeatedly subscribes to this Completable so long as the given * stop supplier returns false. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code repeatUntil} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param stop the supplier that should return true to stop resubscribing. * @return the new Completable instance * @throws NullPointerException if stop is null */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable repeatUntil(BooleanSupplier stop) { return fromObservable(toObservable().repeatUntil(stop)); }
/** * Returns a Completable that subscribes repeatedly at most the given times to this Completable. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code repeat} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param times the number of times the resubscription should happen * @return the new Completable instance * @throws IllegalArgumentException if times is less than zero */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable repeat(long times) { return fromObservable(toObservable().repeat(times)); }
/** * Returns a Completable that subscribes repeatedly at most the given times to this Completable. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code repeat} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param times the number of times the resubscription should happen * @return the new Completable instance * @throws IllegalArgumentException if times is less than zero */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable repeat(long times) { return fromObservable(toObservable().repeat(times)); }
/** * Returns a Completable that retries this Completable in case of an error as long as the predicate * returns true. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code retry} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param predicate the predicate called when this emits an error with the repeat count and the latest exception * and should return true to retry. * @return the new Completable instance */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable retry(BiPredicate<? super Integer, ? super Throwable> predicate) { return fromObservable(toObservable().retry(predicate)); }
/** * Returns a Completable that repeatedly subscribes to this Completable so long as the given * stop supplier returns false. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code repeatUntil} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param stop the supplier that should return true to stop resubscribing. * @return the new Completable instance * @throws NullPointerException if stop is null */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable repeatUntil(BooleanSupplier stop) { return fromObservable(toObservable().repeatUntil(stop)); }
/** * Returns a Completable that retries this Completable in case of an error as long as the predicate * returns true. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code retry} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param predicate the predicate called when this emits an error with the repeat count and the latest exception * and should return true to retry. * @return the new Completable instance */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable retry(BiPredicate<? super Integer, ? super Throwable> predicate) { return fromObservable(toObservable().retry(predicate)); }
/** * Returns a Completable which given an ObservableSource and when this Completable emits an error, delivers * that error through an Observable and the ObservableSource should signal a value indicating a retry in response * or a terminal event indicating a termination. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code retryWhen} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param handler the handler that receives an Observable delivering Throwables and should return an ObservableSource that * emits items to indicate retries or emits terminal events to indicate termination. * @return the new Completable instance * @throws NullPointerException if handler is null */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable retryWhen(Function<? super Observable<Throwable>, ? extends ObservableSource<?>> handler) { return fromObservable(toObservable().retryWhen(handler)); }
@Test(timeout = 5000, expected = TestException.class) public void fromObservableError() { Completable c = Completable.fromObservable(Observable.error(new Callable<Throwable>() { @Override public Throwable call() { return new TestException(); } })); c.blockingAwait(); }
@Test(timeout = 5000) public void fromObservableEmpty() { Completable c = Completable.fromObservable(Observable.empty()); c.blockingAwait(); }
@Test(timeout = 5000) public void fromObservableSome() { for (int n = 1; n < 10000; n *= 10) { Completable c = Completable.fromObservable(Observable.range(1, n)); c.blockingAwait(); } }
@Test public void fromObservableError() { Completable.fromObservable(Observable.error(new UnsupportedOperationException())) .test() .assertFailure(UnsupportedOperationException.class); } }
@Test public void fromObservableEmpty() { Completable.fromObservable(Observable.empty()) .test() .assertResult(); }
@Test public void fromObservable() { Completable.fromObservable(Observable.just(1)) .test() .assertResult(); }