CreateWalletPresenter extends BasePresenter<CreateWalletContract.View> implements CreateWalletContract.Presenter { private void createHDWallet(String name,String password){ WalletManager.getInstance() .createWalletList(name, password) .doOnSuccess(new Consumer<List<Wallet>>() { @Override public void accept(List<Wallet> walletList) throws Exception { List<WalletEntity> walletEntities = new ArrayList<>(); for(int i = 0; i < walletList.size(); i++) { Wallet wallet = walletList.get(i); WalletEntity walletEntity = wallet.buildWalletInfoEntity(); if(i == 1){ walletEntity.setShow(true); } walletEntities.add(walletEntity); } WalletDao.insertWalletInfoList(walletEntities); Wallet subFirstWallet = walletList.get(1); subFirstWallet.setShow(true); WalletManager.getInstance().addAndSelectedWalletStatusNotice(subFirstWallet); PreferenceTool.putBoolean(Constants.Preference.KEY_OPERATE_MENU_FLAG, false); } }) .compose(RxUtils.getSingleSchedulerTransformer()) .compose(RxUtils.bindToLifecycle(getView())) .compose(LoadingTransformer.bindToSingleLifecycle(currentActivity())) .subscribe(new Consumer<List<Wallet>>() { @Override public void accept(List<Wallet> walletList) throws Exception { if (isViewAttached()) { BackupWalletActivity.actionStart(currentActivity(), walletList.get(1)); 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 testCreateHDWallet(){ String name = "Ella"; String password = "123456"; String repeatPassword = "1234567"; presenter.createWallet(name,password,repeatPassword,WalletType.HD_WALLET); Mockito.verify(view).showPasswordError(null,true); }