@Test public void testToMapWithErrorThrowingFactory() { Observable<String> source = Observable.from("a", "bb", "ccc", "dddd"); Func0<Map<Integer, String>> mapFactory = new Func0<Map<Integer, String>>() { @Override public Map<Integer, String> call() { throw new RuntimeException("Forced failure"); } }; Func1<String, Integer> lengthFunc = new Func1<String, Integer>() { @Override public Integer call(String t1) { return t1.length(); } }; Observable<Map<Integer, String>> mapped = Observable.create(OperationToMap.toMap(source, lengthFunc, Functions.<String> identity(), mapFactory)); Map<Integer, String> expected = new LinkedHashMap<Integer, String>(); expected.put(2, "bb"); expected.put(3, "ccc"); expected.put(4, "dddd"); mapped.subscribe(objectObserver); verify(objectObserver, never()).onNext(expected); verify(objectObserver, never()).onCompleted(); verify(objectObserver, times(1)).onError(any(Throwable.class)); }
public static <T, K> OnSubscribeFunc<Map<K, T>> toMap(Observable<T> source, Func1<? super T, ? extends K> keySelector) { return new ToMap<T, K, T>(source, keySelector, Functions.<T> identity(), new DefaultToMapFactory<K, T>()); }
OperationToMap { public static <T, K> OnSubscribeFunc<Map<K, T>> toMap(Observable<T> source, Func1<? super T, ? extends K> keySelector) { return new ToMap<T, K, T>(source, keySelector, Functions.<T> identity(), new DefaultToMapFactory<K, T>()); } }
OperationToMap { public static <T, K> OnSubscribeFunc<Map<K, T>> toMap(Observable<T> source, Func1<? super T, ? extends K> keySelector) { return new ToMap<T, K, T>(source, keySelector, Functions.<T> identity(), new DefaultToMapFactory<K, T>()); }  }
OperationToMap { public static <T, K> OnSubscribeFunc<Map<K, T>> toMap(Observable<T> source, Func1<? super T, ? extends K> keySelector) { return new ToMap<T, K, T>(source, keySelector, Functions.<T> identity(), new DefaultToMapFactory<K, T>()); }  static OnSubscribeFunc<Map<K, T>> toMap(Observable<T> source,
            Func1<? super T, ? extends K> keySelector); static OnSubscribeFunc<Map<K, V>> toMap(Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector); static OnSubscribeFunc<Map<K, V>> toMap(Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector,
            Func0<? extends Map<K, V>> mapFactory); }
OperationToMap { public static <T, K> OnSubscribeFunc<Map<K, T>> toMap(Observable<T> source, Func1<? super T, ? extends K> keySelector) { return new ToMap<T, K, T>(source, keySelector, Functions.<T> identity(), new DefaultToMapFactory<K, T>()); }  static OnSubscribeFunc<Map<K, T>> toMap(Observable<T> source,
            Func1<? super T, ? extends K> keySelector); static OnSubscribeFunc<Map<K, V>> toMap(Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector); static OnSubscribeFunc<Map<K, V>> toMap(Observable<T> source,
            Func1<? super T, ? extends K> keySelector,
            Func1<? super T, ? extends V> valueSelector,
            Func0<? extends Map<K, V>> mapFactory);  }