@Test public void testLoginFailed() throws Exception { String username = "xshengcn"; String password = "password"; when(mDataManager.login(username, password)) .thenReturn(Single.error(mock(HttpException.class))); mPresenter.login(username, password); verify(mLoginView).showLoginDialog(); verify(mLoginView).hideLoginDialog(); verify(mLoginView).loginError(); }
public void login(String username, String password) { final ILoginView view = getView(); view.showLoginDialog(); Disposable disposable = mDataManager.login(username, password) .subscribe(this::handleLoginSuccess, this::handleLoginError); addDisposable(disposable); }
LoginPresenter extends BasePresenter<ILoginView> { public void login(String username, String password) { final ILoginView view = getView(); view.showLoginDialog(); Disposable disposable = mDataManager.login(username, password) .subscribe(this::handleLoginSuccess, this::handleLoginError); addDisposable(disposable); } }
LoginPresenter extends BasePresenter<ILoginView> { public void login(String username, String password) { final ILoginView view = getView(); view.showLoginDialog(); Disposable disposable = mDataManager.login(username, password) .subscribe(this::handleLoginSuccess, this::handleLoginError); addDisposable(disposable); } @Inject  LoginPresenter(DataManager dataManager, PreferencesHelper preferencesHelper); }
LoginPresenter extends BasePresenter<ILoginView> { public void login(String username, String password) { final ILoginView view = getView(); view.showLoginDialog(); Disposable disposable = mDataManager.login(username, password) .subscribe(this::handleLoginSuccess, this::handleLoginError); addDisposable(disposable); } @Inject  LoginPresenter(DataManager dataManager, PreferencesHelper preferencesHelper); @Override void onAttach(ILoginView view); void login(String username, String password); }
LoginPresenter extends BasePresenter<ILoginView> { public void login(String username, String password) { final ILoginView view = getView(); view.showLoginDialog(); Disposable disposable = mDataManager.login(username, password) .subscribe(this::handleLoginSuccess, this::handleLoginError); addDisposable(disposable); } @Inject  LoginPresenter(DataManager dataManager, PreferencesHelper preferencesHelper); @Override void onAttach(ILoginView view); void login(String username, String password);  }