CreateWalletPresenter extends BasePresenter<CreateWalletContract.View> implements CreateWalletContract.Presenter { private void createOrdinaryWallet(String name,String password){ WalletManager.getInstance() .createWallet(name, password) .doOnSuccess(new Consumer<Wallet>() { @Override public void accept(Wallet walletEntity) throws Exception { WalletDao.insertWalletInfo(walletEntity.buildWalletInfoEntity()); WalletManager.getInstance().addAndSelectedWalletStatusNotice(walletEntity); PreferenceTool.putBoolean(Constants.Preference.KEY_OPERATE_MENU_FLAG, false); } }) .compose(RxUtils.getSingleSchedulerTransformer()) .compose(RxUtils.bindToLifecycle(getView())) .compose(LoadingTransformer.bindToSingleLifecycle(currentActivity())) .subscribe(new Consumer<Wallet>() { @Override public void accept(Wallet walletEntity) throws Exception { if (isViewAttached()) { BackupWalletActivity.actionStart(currentActivity(), walletEntity); currentActivity().finish(); } } }, new Consumer<Throwable>() { @Override public void accept(Throwable throwable) throws Exception { if (isViewAttached() && throwable instanceof CustomThrowable) { CustomThrowable customThrowable = (CustomThrowable) throwable; if (customThrowable.getDetailMsgRes() != -1) { showLongToast(customThrowable.getDetailMsgRes()); } } } }); }  @Override void loadDBWalletNumber(); @SuppressLint("CheckResult") @Override void createWallet(String name, String password, String repeatPassword,  @WalletType int walletType);  }
@Test public void testCreateOrdinaryWallet(){ String name = "Ella"; String password = "123456"; String repeatPassword = "1234567"; presenter.createWallet(name,password,repeatPassword,WalletType.ORDINARY_WALLET); Mockito.verify(view).showPasswordError(null,true); }