@Test public void testToMultimapWithThrowingCollectionFactory() { Observable<String> source = Observable.from("cc", "cc", "eee", "eee"); Func1<Integer, Collection<String>> collectionFactory = new Func1<Integer, Collection<String>>() { @Override public Collection<String> call(Integer t1) { if (t1 == 2) { throw new RuntimeException("Forced failure"); } else { return new HashSet<String>(); } } }; Observable<Map<Integer, Collection<String>>> mapped = Observable.create( OperationToMultimap.toMultimap( source, lengthFunc, Functions.<String> identity(), new DefaultToMultimapFactory(), collectionFactory)); Map<Integer, Collection<String>> expected = new HashMap<Integer, Collection<String>>(); expected.put(2, Arrays.asList("cc", "dd")); expected.put(3, Collections.singleton("eee")); mapped.subscribe(objectObserver); verify(objectObserver, times(1)).onError(any(Throwable.class)); verify(objectObserver, never()).onNext(expected); verify(objectObserver, never()).onCompleted(); }
public static <T, K> OnSubscribeFunc<Map<K, Collection<T>>> toMultimap( Observable<T> source, Func1<? super T, ? extends K> keySelector ) { return new ToMultimap<T, K, T>( source, keySelector, Functions.<T> identity(), new DefaultToMultimapFactory<K, T>(), new DefaultMultimapCollectionFactory<K, T>()); }
OperationToMultimap { public static <T, K> OnSubscribeFunc<Map<K, Collection<T>>> toMultimap( Observable<T> source, Func1<? super T, ? extends K> keySelector ) { return new ToMultimap<T, K, T>( source, keySelector, Functions.<T> identity(), new DefaultToMultimapFactory<K, T>(), new DefaultMultimapCollectionFactory<K, T>()); } }
OperationToMultimap { public static <T, K> OnSubscribeFunc<Map<K, Collection<T>>> toMultimap( Observable<T> source, Func1<? super T, ? extends K> keySelector ) { return new ToMultimap<T, K, T>( source, keySelector, Functions.<T> identity(), new DefaultToMultimapFactory<K, T>(), new DefaultMultimapCollectionFactory<K, T>()); }  }
OperationToMultimap { public static <T, K> OnSubscribeFunc<Map<K, Collection<T>>> toMultimap( Observable<T> source, Func1<? super T, ? extends K> keySelector ) { return new ToMultimap<T, K, T>( source, keySelector, Functions.<T> identity(), new DefaultToMultimapFactory<K, T>(), new DefaultMultimapCollectionFactory<K, T>()); }  static OnSubscribeFunc<Map<K, Collection<T>>> toMultimap(
            Observable<T> source,
            Func1<? super T, ? extends K> keySelector
            ); static OnSubscribeFunc<Map<K, Collection<V>>> toMultimap(
            Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector
            ); static OnSubscribeFunc<Map<K, Collection<V>>> toMultimap(
            Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector,
            Func0<? extends Map<K, Collection<V>>> mapFactory
            ); static OnSubscribeFunc<Map<K, Collection<V>>> toMultimap(
            Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector,
            Func0<? extends Map<K, Collection<V>>> mapFactory,
            Func1<? super K, ? extends Collection<V>> collectionFactory
            ); }
OperationToMultimap { public static <T, K> OnSubscribeFunc<Map<K, Collection<T>>> toMultimap( Observable<T> source, Func1<? super T, ? extends K> keySelector ) { return new ToMultimap<T, K, T>( source, keySelector, Functions.<T> identity(), new DefaultToMultimapFactory<K, T>(), new DefaultMultimapCollectionFactory<K, T>()); }  static OnSubscribeFunc<Map<K, Collection<T>>> toMultimap(
            Observable<T> source,
            Func1<? super T, ? extends K> keySelector
            ); static OnSubscribeFunc<Map<K, Collection<V>>> toMultimap(
            Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector
            ); static OnSubscribeFunc<Map<K, Collection<V>>> toMultimap(
            Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector,
            Func0<? extends Map<K, Collection<V>>> mapFactory
            ); static OnSubscribeFunc<Map<K, Collection<V>>> toMultimap(
            Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector,
            Func0<? extends Map<K, Collection<V>>> mapFactory,
            Func1<? super K, ? extends Collection<V>> collectionFactory
            );  }