@Test
public void testMinWithComparator() {

    Observable<Integer> observable = min(Observable.from(2, 3, 1, 4),
            new Comparator<Integer>() {
                @Override
                public int compare(Integer o1, Integer o2) {
                    return o2 - o1;
                }
            });
    @SuppressWarnings("unchecked")
    Observer<Integer> observer = (Observer<Integer>) mock(Observer.class);
    observable.subscribe(observer);
    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onNext(4);
    inOrder.verify(observer, times(1)).onCompleted();
    inOrder.verifyNoMoreInteractions();
}