@Test
public void testToMap() {

    Observable<String> source = Observable.from("a", "bb", "ccc", "dddd");
    Observable<Map<Integer, String>> mapped = Observable.create(OperationToMap.toMap(source, lengthFunc));
    Map<Integer, String> expected = new HashMap<Integer, String>();
    expected.put(1, "a");
    expected.put(2, "bb");
    expected.put(3, "ccc");
    expected.put(4, "dddd");
    mapped.subscribe(objectObserver);
    verify(objectObserver, never()).onError(any(Throwable.class));
    verify(objectObserver, times(1)).onNext(expected);
    verify(objectObserver, times(1)).onCompleted();
}