CakePresenter extends BasePresenter<MainView> implements Observer<CakesResponse> { @Override public void onError(Throwable e) { getView().onHideDialog(); getView().onShowToast("Error loading cakes " + e.getMessage()); } @Inject  CakePresenter(); void getCakes(); @Override void onCompleted(); @Override void onError(Throwable e); @Override void onNext(CakesResponse cakesResponse); void getCakesFromDatabase();  }
@Test public void onError() throws Exception { presenter.onError(new Throwable(TEST_ERROR_MESSAGE)); verify(mView, times(1)).onHideDialog(); verify(mView, times(1)).onShowToast("Error loading cakes " + TEST_ERROR_MESSAGE); }