@Test(expected = NullPointerException.class) public void concatNull() { Completable.concatArray((Completable[])null); }
/** * Returns a Completable which first runs the other Completable * then this completable if the other completed normally. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code startWith} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param other the other completable to run first * @return the new Completable instance * @throws NullPointerException if other is null */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable startWith(CompletableSource other) { ObjectHelper.requireNonNull(other, "other is null"); return concatArray(other, this); }
/** * Concatenates this Completable with another Completable. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code concatWith} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param other the other Completable, not null * @return the new Completable which subscribes to this and then the other Completable * @throws NullPointerException if other is null */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable concatWith(CompletableSource other) { ObjectHelper.requireNonNull(other, "other is null"); return concatArray(this, other); }
/** * Concatenates this Completable with another Completable. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code concatWith} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param other the other Completable, not null * @return the new Completable which subscribes to this and then the other Completable * @throws NullPointerException if other is null */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable concatWith(CompletableSource other) { ObjectHelper.requireNonNull(other, "other is null"); return concatArray(this, other); }
/** * Returns a Completable which first runs the other Completable * then this completable if the other completed normally. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code startWith} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param other the other completable to run first * @return the new Completable instance * @throws NullPointerException if other is null */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable startWith(CompletableSource other) { ObjectHelper.requireNonNull(other, "other is null"); return concatArray(other, this); }
@Test(timeout = 5000, expected = TestException.class) public void concatMultipleOneThrows() { Completable c = Completable.concatArray(normal.completable, error.completable, normal.completable); c.blockingAwait(); }
@Test(timeout = 5000, expected = TestException.class) public void concatSingleSourceThrows() { Completable c = Completable.concatArray(error.completable); c.blockingAwait(); }
@Test(timeout = 5000, expected = NullPointerException.class) public void concatMultipleOneIsNull() { Completable c = Completable.concatArray(normal.completable, null); c.blockingAwait(); }
@Test(timeout = 5000) public void concatEmpty() { Completable c = Completable.concatArray(); c.blockingAwait(); }
@Test(timeout = 5000) public void concatMultipleSources() { Completable c = Completable.concatArray(normal.completable, normal.completable, normal.completable); c.blockingAwait(); normal.assertSubscriptions(3); }
@Test(timeout = 5000) public void concatSingleSource() { Completable c = Completable.concatArray(normal.completable); c.blockingAwait(); normal.assertSubscriptions(1); }
@Test public void arrayCancelRace() { Completable[] a = new Completable[1024]; Arrays.fill(a, Completable.complete()); for (int i = 0; i < 500; i++) { final Completable c = Completable.concatArray(a); final TestObserver<Void> to = new TestObserver<Void>(); Runnable r1 = new Runnable() { @Override public void run() { c.subscribe(to); } }; Runnable r2 = new Runnable() { @Override public void run() { to.cancel(); } }; TestCommonHelper.race(r1, r2, Schedulers.single()); } }
@Test public void arrayCancelled() { Completable.concatArray(Completable.complete(), Completable.complete()) .test(true) .assertEmpty(); }
@Test public void arrayFirstCancels() { final TestObserver<Void> to = new TestObserver<Void>(); Completable.concatArray(new Completable() { @Override protected void subscribeActual(CompletableObserver s) { s.onSubscribe(Disposables.empty()); to.cancel(); s.onComplete(); } }, Completable.complete()) .subscribe(to); to.assertEmpty(); }