@Test
public void testFlatMapTransformsException() {

    Flowable<Integer> onNext = Flowable.fromIterable(Arrays.asList(1, 2, 3));
    Flowable<Integer> onComplete = Flowable.fromIterable(Arrays.asList(4));
    Flowable<Integer> onError = Flowable.fromIterable(Arrays.asList(5));
    Flowable<Integer> source = Flowable.concat(
            Flowable.fromIterable(Arrays.asList(10, 20, 30)),
            Flowable.<Integer> error(new RuntimeException("Forced failure!"))
            );
    Subscriber<Object> o = TestHelper.mockSubscriber();
    source.flatMap(just(onNext), just(onError), just0(onComplete)).subscribe(o);
    verify(o, times(3)).onNext(1);
    verify(o, times(3)).onNext(2);
    verify(o, times(3)).onNext(3);
    verify(o).onNext(5);
    verify(o).onComplete();
    verify(o, never()).onNext(4);
    verify(o, never()).onError(any(Throwable.class));
}