@Override public CompletableSource apply(Integer v) throws Exception { return Completable.error(new TestException()); } }, true)
@Override public CompletableSource apply(Object v) throws Exception { return Completable.error(new TestException("Main")); } }, new Consumer<Object>() {
@Override public CompletableSource apply(Integer v) throws Exception { return Completable.error(new TestException()); } }, true, Integer.MAX_VALUE).<Integer>toFlowable()
@Override public CompletableSource apply(Integer v) throws Exception { return Completable.error(new TestException()); } }, true).<Integer>toObservable()
@Override public Completable apply(Integer v) throws Exception { sleep(); return Completable.error(new TestException()); } })
@Test(timeout = 5000, expected = TestException.class) public void errorSupplierNormal() { Completable c = Completable.error(new Callable<Throwable>() { @Override public Throwable call() { return new TestException(); } }); c.blockingAwait(); }
@Test(timeout = 5000, expected = NullPointerException.class) public void errorSupplierReturnsNull() { Completable c = Completable.error(new Callable<Throwable>() { @Override public Throwable call() { return null; } }); c.blockingAwait(); }
@Override public Completable apply(Integer v) throws Exception { sleep(); return Completable.error(new TestException()); } })
@Test public void completableSubscribe0() { Completable.error(new TestException()) .subscribe(); }
@Test public void fromCompletableError() { Maybe.fromCompletable(Completable.error(new UnsupportedOperationException())) .test() .assertFailure(UnsupportedOperationException.class); }
@Test public void blockingGetError() { TestException ex = new TestException(); assertSame(ex, Completable.error(ex).blockingGet()); }
@Test public void otherError() { final TestObserver<Integer> to = new TestObserver<Integer>(); Observable.range(1, 5) .concatWith(Completable.error(new TestException())) .subscribe(to); to.assertFailure(TestException.class, 1, 2, 3, 4, 5); }
@Test public void completableToMaybeError() { Completable.error(new TestException()) .toMaybe() .test() .assertFailure(TestException.class); }
@Test public void andThenMaybeError() { Completable.error(new RuntimeException("bla")) .andThen(Maybe.empty()) .test() .assertNotComplete() .assertNoValues() .assertError(RuntimeException.class) .assertErrorMessage("bla"); } }
@Test @SuppressWarnings("unchecked") public void error() { TestException ex = new TestException(); Completable.error(ex) .materialize() .test() .assertResult(Notification.createOnError(ex)); }
@Test public void otherError() { Flowable.never() .mergeWith(Completable.error(new TestException())) .test() .assertFailure(TestException.class); }
@Test public void innerError() { Flowable.just(1) .concatMapCompletable(Functions.justFunction(Completable.error(new TestException()))) .test() .assertFailure(TestException.class); }
@Test public void andThenCompletableErrorNever() { Completable.error(new TestException("bla")) .andThen(Completable.never()) .test() .assertNotComplete() .assertNoValues() .assertError(TestException.class) .assertErrorMessage("bla"); }
@Test public void errorNotDelayed() { TestScheduler scheduler = new TestScheduler(); TestObserver<Void> to = Completable.error(new TestException()) .delay(100, TimeUnit.MILLISECONDS, scheduler, false) .test(); to.assertEmpty(); scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); to.assertFailure(TestException.class); scheduler.advanceTimeBy(100, TimeUnit.MILLISECONDS); to.assertFailure(TestException.class); }