@Test
public void testToMultimapWithError() {

    Observable<String> source = Observable.from("a", "b", "cc", "dd");
    Func1<String, Integer> lengthFuncErr = new Func1<String, Integer>() {
        @Override
        public Integer call(String t1) {
            if ("b".equals(t1)) {
                throw new RuntimeException("Forced Failure");
            }
            return t1.length();
        }
    };
    Observable<Map<Integer, Collection<String>>> mapped = Observable.create(OperationToMultimap.toMultimap(source, lengthFuncErr));
    Map<Integer, Collection<String>> expected = new HashMap<Integer, Collection<String>>();
    expected.put(1, Arrays.asList("a", "b"));
    expected.put(2, Arrays.asList("cc", "dd"));
    mapped.subscribe(objectObserver);
    verify(objectObserver, times(1)).onError(any(Throwable.class));
    verify(objectObserver, never()).onNext(expected);
    verify(objectObserver, never()).onCompleted();
}