RxUi { public static <T> Disposable bind(Observable<T> observable, Function<Observable<T>, Disposable> uiFunc) { try { return uiFunc.apply(observable); } catch (Exception exception) { throw new RuntimeException(exception); } }  static Disposable bind(Observable<T> observable, Function<Observable<T>, Disposable> uiFunc); static Function<Observable<T>, Disposable> ui(final Consumer<T> uiAction);  }
@Test public void bind() throws Exception { Observable<String> observable = Observable.just("value"); Function<Observable<String>, Disposable> uiFunc = mock(Function.class); Disposable expectedDisposable = mock(Disposable.class); when(uiFunc.apply(observable)).thenReturn(expectedDisposable); Disposable actualDisposable = RxUi.bind(observable, uiFunc); verify(uiFunc).apply(observable); assertThat(actualDisposable).isSameAs(expectedDisposable); }