@Test(expected = NullPointerException.class) public void concatIterableNull() { Flowable.concat((Iterable<Publisher<Object>>)null); }
@Test(expected = NullPointerException.class) public void concatFlowableNull() { Flowable.concat((Flowable<Flowable<Object>>)null); }
@SuppressWarnings("unchecked") @Test(expected = NullPointerException.class) public void concatIterableOneIsNull() { Flowable.concat(Arrays.asList(just1, null)).blockingLast(); }
@Test(expected = NullPointerException.class) public void concatIterableIteratorNull() { Flowable.concat(new Iterable<Publisher<Object>>() { @Override public Iterator<Publisher<Object>> iterator() { return null; } }).blockingLast(); }
@Override public Flowable<Integer> apply(Flowable<Integer> f) { return Flowable.concat(f.take(5), f.takeLast(5)); } }).subscribe(ts);
@Override public Flowable<Integer> apply(Flowable<Integer> f) { return Flowable.concat(f.take(5), f.takeLast(5)); } }).subscribe(ts);
@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 public void testConcat() { Subscriber<String> subscriber = TestHelper.mockSubscriber(); final String[] o = { "1", "3", "5", "7" }; final String[] e = { "2", "4", "6" }; final Flowable<String> odds = Flowable.fromArray(o); final Flowable<String> even = Flowable.fromArray(e); Flowable<String> concat = Flowable.concat(odds, even); concat.subscribe(subscriber); verify(subscriber, times(7)).onNext(anyString()); }
@Test public void concat3() { Flowable<Integer> source = Flowable.just(1); Flowable.concat(source, source, source) .test() .assertResult(1, 1, 1); }
@Override public Publisher<Long> createPublisher(long elements) { return Flowable.concat( Flowable.fromIterable(iterate(elements / 2)), Flowable.fromIterable(iterate(elements - elements / 2)) ) ; } }
@Test public void testWithError3Flowable() { Flowable<Boolean> flowable = Flowable.sequenceEqual( Flowable.concat(Flowable.just("one"), Flowable.<String> error(new TestException())), Flowable.concat(Flowable.just("one"), Flowable.<String> error(new TestException()))).toFlowable(); verifyError(flowable); }
@Test public void workerNotDisposedPrematurelySyncInNormalOut() { DisposeTrackingScheduler s = new DisposeTrackingScheduler(); Flowable.concat( Flowable.just(1).observeOn(s), Flowable.just(2) ) .test() .assertResult(1, 2); assertEquals(1, s.disposedCount.get()); }
@Test public void workerNotDisposedPrematurelySyncInNormalOutConditional() { DisposeTrackingScheduler s = new DisposeTrackingScheduler(); Flowable.concat( Flowable.just(1).observeOn(s).filter(Functions.alwaysTrue()), Flowable.just(2) ) .test() .assertResult(1, 2); assertEquals(1, s.disposedCount.get()); }
@Test public void testWithError2() { Single<Boolean> single = Flowable.sequenceEqual( Flowable.just("one", "two", "three"), Flowable.concat(Flowable.just("one"), Flowable.<String> error(new TestException()))); verifyError(single); }
@Test public void testWithError1() { Single<Boolean> single = Flowable.sequenceEqual( Flowable.concat(Flowable.just("one"), Flowable.<String> error(new TestException())), Flowable.just("one", "two", "three")); verifyError(single); }
@Test public void workerNotDisposedPrematurelyNormalInNormalOutConditional() { DisposeTrackingScheduler s = new DisposeTrackingScheduler(); Flowable.concat( Flowable.just(1).hide().observeOn(s).filter(Functions.alwaysTrue()), Flowable.just(2) ) .test() .assertResult(1, 2); assertEquals(1, s.disposedCount.get()); }
@Test public void testWithError2Flowable() { Flowable<Boolean> flowable = Flowable.sequenceEqual( Flowable.just("one", "two", "three"), Flowable.concat(Flowable.just("one"), Flowable.<String> error(new TestException()))).toFlowable(); verifyError(flowable); }
@Test public void testWithError1Flowable() { Flowable<Boolean> flowable = Flowable.sequenceEqual( Flowable.concat(Flowable.just("one"), Flowable.<String> error(new TestException())), Flowable.just("one", "two", "three")).toFlowable(); verifyError(flowable); }
@Test public void testError2() { Flowable<Integer> source = Flowable.concat(Flowable.just(0), Flowable.<Integer> error(new TestException("Forced failure"))); Flowable<Integer> m = source.groupBy(identity, dbl).flatMap(FLATTEN_INTEGER); TestSubscriber<Object> ts = new TestSubscriber<Object>(); m.subscribe(ts); ts.awaitTerminalEvent(); assertEquals(1, ts.errorCount()); ts.assertValueCount(1); }