@Test public void testCountError() { Flowable<String> f = Flowable.error(new Callable<Throwable>() { @Override public Throwable call() { return new RuntimeException(); } }); f.count().subscribe(wo); verify(wo, never()).onSuccess(anyInt()); verify(wo, times(1)).onError(any(RuntimeException.class)); }
@Test(expected = NullPointerException.class) public void testForEachWithNull() { Flowable.error(new Exception("boo")) // .forEach(null); }
@Test(timeout = 2000) public void testRepeatError() { Subscriber<Object> subscriber = TestHelper.mockSubscriber(); Flowable.error(new TestException()).repeat(10).subscribe(subscriber); verify(subscriber).onError(any(TestException.class)); verify(subscriber, never()).onNext(any()); verify(subscriber, never()).onComplete(); }
@Test public void testSkipError() { Exception e = new Exception(); Flowable<String> ok = Flowable.just("one"); Flowable<String> error = Flowable.error(e); Flowable<String> skip = Flowable.concat(ok, error).skip(100); Subscriber<String> subscriber = TestHelper.mockSubscriber(); skip.subscribe(subscriber); verify(subscriber, never()).onNext(any(String.class)); verify(subscriber, times(1)).onError(e); verify(subscriber, never()).onComplete(); }
@Test(/* timeout = 1000, */expected = RuntimeException.class) public void testHasNextThrows() { TestScheduler scheduler = new TestScheduler(); Flowable<Long> source = Flowable.<Long> error(new RuntimeException("Forced failure!")).subscribeOn(scheduler); Iterable<Long> iter = source.blockingLatest(); Iterator<Long> it = iter.iterator(); scheduler.advanceTimeBy(1, TimeUnit.SECONDS); it.hasNext(); }
@Test public void testAssertError() { RuntimeException e = new RuntimeException("Oops"); TestSubscriber<Object> subscriber = new TestSubscriber<Object>(); Flowable.error(e).subscribe(subscriber); subscriber.assertError(e); }
@Test(timeout = 5000, expected = TestException.class) public void concatObservableError() { Completable c = Completable.concat(Flowable.<Completable>error(new Callable<Throwable>() { @Override public Throwable call() { return new TestException(); } })); c.blockingAwait(); }
@Test(timeout = 5000, expected = TestException.class) public void mergeObservableError() { Completable c = Completable.merge(Flowable.<Completable>error(new Callable<Throwable>() { @Override public Throwable call() { return new TestException(); } })); c.blockingAwait(); }
@Test(timeout = 5000, expected = TestException.class) public void mergeDelayErrorObservableError() { Completable c = Completable.mergeDelayError(Flowable.<Completable>error(new Callable<Throwable>() { @Override public Throwable call() { return new TestException(); } })); c.blockingAwait(); }
@Test public void flowableBoundedBlockingSubscribe1() { Flowable.error(new TestException()) .blockingSubscribe(Functions.emptyConsumer(), 128); }
@Test public void error() { Flowable.error(new TestException()) .throttleLatest(1, TimeUnit.MINUTES) .test() .assertFailure(TestException.class); }
@Test public void error() { Flowable.error(new TestException()) .takeLast(5) .test() .assertFailure(TestException.class); }
@Test public void fromFlowableError() { Flowable.error(new TestException()) .singleElement() .test() .assertFailure(TestException.class); }
@Test public void error() { Flowable.error(new TestException()) .skipWhile(Functions.alwaysFalse()) .test() .assertFailure(TestException.class); } }
@Test public void dontRetry() { Flowable.error(new TestException("Outer")) .retry(Functions.alwaysFalse()) .test() .assertFailureAndMessage(TestException.class, "Outer"); }
@Test public void mainError() { Flowable.error(new TestException()) .window(Functions.justCallable(Flowable.never())) .test() .assertError(TestException.class); }
@Test public void boundaryOnError() { TestSubscriber<Object> ts = Flowable.error(new TestException()) .window(Flowable.never()) .flatMap(Functions.<Flowable<Object>>identity(), true) .test() .assertFailure(CompositeException.class); List<Throwable> errors = TestHelper.compositeList(ts.errors().get(0)); TestHelper.assertError(errors, 0, TestException.class); }
@Test(timeout = 5000) public void startWithFlowableError() { Flowable<Object> c = normal.completable .startWith(Flowable.error(new TestException())); TestSubscriber<Object> ts = new TestSubscriber<Object>(); c.subscribe(ts); normal.assertSubscriptions(0); ts.assertNoValues(); ts.assertError(TestException.class); ts.assertNotComplete(); }
@Test public void boundaryError() { BehaviorProcessor.createDefault(1) .window(Functions.justCallable(Flowable.error(new TestException()))) .test() .assertValueCount(1) .assertNotComplete() .assertError(TestException.class); }