@Test
public void concatMapDelayError() {

    final int[] count = { 0 };
    Flowable.range(1, 5)
    .parallel(2)
    .concatMapDelayError(new Function<Integer, Flowable<Integer>>() {
        @Override
        public Flowable<Integer> apply(Integer v) throws Exception {
            if (v == 3) {
               return Flowable.error(new TestException());
            }
            return Flowable.just(v);
        }
    }, true)
    .doOnError(new Consumer<Throwable>() {
        @Override
        public void accept(Throwable e) throws Exception {
            if (e instanceof TestException) {
                count[0]++;
            }
        }
    })
    .sequential()
    .test()
    .assertValues(1, 2, 4, 5)
    .assertError(TestException.class)
    .assertNotComplete();
    assertEquals(1, count[0]);
}