@Override public Flowable<Long> apply(Long t) { return Flowable.fromIterable(Arrays.asList(1L, 2L, 3L)).hide(); } }).take(3)).subscribe(ts);
@Override public Flowable<Integer> apply(Integer t) { return Flowable.just(t).hide(); } };
@Override public Object apply(Flowable<Integer> f) throws Exception { return f.concatMap(Functions.justFunction(Flowable.just(1).hide())); } }, true, 1, 1, 1);
@Override public Flowable<Integer> apply(Integer t) { return Flowable.range(1, Flowable.bufferSize() * 2) .doOnNext(new Consumer<Integer>() { @Override public void accept(Integer t) { count.getAndIncrement(); } }).hide(); } }).subscribe(ts);
@Test public void mapperThrows() { Flowable.just(1).hide() .switchMap(new Function<Integer, Flowable<Object>>() { @Override public Flowable<Object> apply(Integer v) throws Exception { throw new TestException(); } }) .test() .assertFailure(TestException.class); }
@Test public void innerError() { Flowable.<Integer>just(1).hide().concatMapEager(new Function<Integer, Flowable<Integer>>() { @Override public Flowable<Integer> apply(Integer v) throws Exception { return Flowable.error(new TestException()); } }) .test() .assertFailure(TestException.class); }
@Test public void oneByOne() { Flowable.range(1, 3).hide() .flatMapIterable(Functions.justFunction(Arrays.asList(1)), 1) .rebatchRequests(1) .test() .assertResult(1, 1, 1); }
@Test public void dispose() { TestHelper.checkDisposed(Flowable.switchOnNext( Flowable.just(Flowable.just(1)).hide())); }
@Test public void innerErrorMaxConcurrency() { Flowable.<Integer>just(1).hide().concatMapEager(new Function<Integer, Flowable<Integer>>() { @Override public Flowable<Integer> apply(Integer v) throws Exception { return Flowable.error(new TestException()); } }, 1, 128) .test() .assertFailure(TestException.class); }
@Test public void mergeScalar2() { Flowable.merge(Flowable.just(Flowable.just(1)).hide()) .test() .assertResult(1); }
@Test public void unboundedIn() { Completable.concat(Flowable.just(Completable.complete()).hide(), Integer.MAX_VALUE) .test() .assertResult(); }
@Test public void mergeScalarEmpty() { Flowable.merge(Flowable.just(Flowable.empty()).hide()) .test() .assertResult(); }
@Test public void workerNotDisposedPrematurelyNormalInNormalOut() { DisposeTrackingScheduler s = new DisposeTrackingScheduler(); Flowable.concat( Flowable.just(1).hide().observeOn(s), Flowable.just(2) ) .test() .assertResult(1, 2); assertEquals(1, s.disposedCount.get()); }
@Test public void concatMapScalarBackpressuredDelayError() { Flowable.just(1).hide() .concatMapDelayError(Functions.justFunction(Flowable.just(2))) .test(1L) .assertResult(2); }
@Test public void callableCrash() { Flowable.just(1).hide() .concatMap(Functions.justFunction(Flowable.fromCallable(new Callable<Object>() { @Override public Object call() throws Exception { throw new TestException(); } }))) .test() .assertFailure(TestException.class); }
@Test public void concatMapEmpty() { Flowable.just(1).hide() .concatMap(Functions.justFunction(Flowable.empty())) .test() .assertResult(); }
@Test public void syncIterableHidden() { Flowable.fromIterable(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) .hide() .to(SubscriberFusion.<Integer>test(Long.MAX_VALUE, QueueFuseable.ANY, false)) .assertOf(SubscriberFusion.<Integer>assertNotFuseable()) .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.NONE)) .assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) .assertNoErrors() .assertComplete(); } }
@Test public void doubleObserveOn() { Flowable.just(1).hide() .observeOn(Schedulers.computation()) .observeOn(Schedulers.single()) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(1); }
@Test public void cancelBeforeActualSubscribe() { TestScheduler test = new TestScheduler(); TestSubscriber<Integer> ts = Flowable.just(1).hide() .subscribeOn(test).test(Long.MAX_VALUE, true); test.advanceTimeBy(1, TimeUnit.SECONDS); ts .assertSubscribed() .assertNoValues() .assertNotTerminated(); }