@Test(expected = NullPointerException.class) public void mergeNull() { Completable.mergeArray((Completable[])null); }
/** * Returns a Completable which subscribes to this and the other Completable and completes * when both of them complete or one emits an error. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code mergeWith} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param other the other Completable instance * @return the new Completable instance * @throws NullPointerException if other is null */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable mergeWith(CompletableSource other) { ObjectHelper.requireNonNull(other, "other is null"); return mergeArray(this, other); }
/** * Returns a Completable which subscribes to this and the other Completable and completes * when both of them complete or one emits an error. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code mergeWith} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param other the other Completable instance * @return the new Completable instance * @throws NullPointerException if other is null */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Completable mergeWith(CompletableSource other) { ObjectHelper.requireNonNull(other, "other is null"); return mergeArray(this, other); }
@Test(timeout = 5000) public void mergeEmpty() { Completable c = Completable.mergeArray(); c.blockingAwait(); }
@Test(timeout = 5000, expected = NullPointerException.class) public void mergeMultipleOneIsNull() { Completable c = Completable.mergeArray(normal.completable, null); c.blockingAwait(); }
@Test(timeout = 5000, expected = TestException.class) public void mergeSingleSourceThrows() { Completable c = Completable.mergeArray(error.completable); c.blockingAwait(); }
@Test(timeout = 5000, expected = TestException.class) public void mergeMultipleOneThrows() { Completable c = Completable.mergeArray(normal.completable, error.completable, normal.completable); c.blockingAwait(); }
@Test(timeout = 5000) public void mergeSingleSource() { Completable c = Completable.mergeArray(normal.completable); c.blockingAwait(); normal.assertSubscriptions(1); }
@Test(timeout = 5000) public void mergeMultipleSources() { Completable c = Completable.mergeArray(normal.completable, normal.completable, normal.completable); c.blockingAwait(); normal.assertSubscriptions(3); }
@Test public void cancelAfterFirst() { final TestObserver<Void> to = new TestObserver<Void>(); Completable.mergeArray(new Completable() { @Override protected void subscribeActual(CompletableObserver s) { s.onSubscribe(Disposables.empty()); s.onComplete(); to.cancel(); } }, Completable.complete()) .subscribe(to); to.assertEmpty(); }
@Test public void completeAfterMain() { CompletableSubject pp = CompletableSubject.create(); TestObserver<Void> to = Completable.mergeArray(Completable.complete(), pp) .test(); pp.onComplete(); to.assertResult(); }
final CompletableSubject pp2 = CompletableSubject.create(); TestObserver<Void> to = Completable.mergeArray(pp1, pp2).test();