@Test
public void testCollectionFunctionThrows() {

    Subscriber<Object> o = TestHelper.mockSubscriber();
    Function<Integer, List<Integer>> func = new Function<Integer, List<Integer>>() {
        @Override
        public List<Integer> apply(Integer t1) {
            throw new TestException();
        }
    };
    BiFunction<Integer, Integer, Integer> resFunc = new BiFunction<Integer, Integer, Integer>() {
        @Override
        public Integer apply(Integer t1, Integer t2) {
            return t1 | t2;
        }
    };
    List<Integer> source = Arrays.asList(16, 32, 64);
    Flowable.fromIterable(source).flatMapIterable(func, resFunc).subscribe(o);
    verify(o, never()).onComplete();
    verify(o, never()).onNext(any());
    verify(o).onError(any(TestException.class));
}