WithDrawPresenter extends BasePresenter<WithDrawContract.View> implements WithDrawContract.Presenter { @Override public void checkWithDrawAmount(String withdrawAmount) { if (mDelegationValue != null) { String minDelegation = mDelegationValue.getMinDelegation(); String minDelegationAmount = AmountUtil.convertVonToLat(mDelegationValue.getMinDelegation()); boolean isWithdrawAmountBiggerThanMinDelegation = BigDecimalUtil.isNotSmaller(withdrawAmount, minDelegationAmount); if(TextUtils.isEmpty(withdrawAmount)){ getView().showTips(false, NumberParserUtils.getPrettyNumber(minDelegationAmount)); }else if(isWithdrawAmountBiggerThanMinDelegation){ getView().showTips(false, NumberParserUtils.getPrettyNumber(minDelegationAmount)); }else{ getView().showTips(true, NumberParserUtils.getPrettyNumber(minDelegationAmount)); } if (mWithDrawBalance != null && mWithDrawBalance.isDelegated()) { String leftWithdrawAmount = BigDecimalUtil.sub(mWithDrawBalance.getDelegated(), Convert.toVon(BigDecimalUtil.toBigDecimal(withdrawAmount), Convert.Unit.LAT).toPlainString()).toPlainString(); boolean isLeftWithdrawAmountSmallerThanMinDelegation = BigDecimalUtil.isBiggerThanZero(leftWithdrawAmount) && !BigDecimalUtil.isNotSmaller(leftWithdrawAmount, minDelegation); if (isLeftWithdrawAmountSmallerThanMinDelegation) { getView().setAllAmountDelegate(); } } } }  WithDrawBalance getmWithDrawBalance(); void setmWithDrawBalance(WithDrawBalance mWithDrawBalance); DelegateItemInfo getmDelegateDetail(); void setmDelegateDetail(DelegateItemInfo mDelegateDetail); DelegationValue getmDelegationValue(); void setmDelegationValue(DelegationValue mDelegationValue); Wallet getmWallet(); void setmWallet(Wallet mWallet); @Override void init(DelegateItemInfo delegateItemInfo); String getWalletAddress(); List<WithDrawBalance> getWithDrawBalanceList(); WithDrawBalance getWithDrawBalance(); double getMinDelegationAmount(); @Override void showWalletInfo(); void getEstimateGas(String prefixAddress, String nodeId); @Override void checkWithDrawAmount(String withdrawAmount); @Override void updateWithDrawButtonState(); @Override void getBalanceType(); @Override void getWithDrawGasPrice(String gasPrice); @Override void showSelectDelegationsDialogFragment(); @SuppressLint("CheckResult") @Override void submitWithDraw(); @SuppressLint("CheckResult") void withdraw(Credentials credentials, GasProvider gasProvider, String nodeId, String nodeName, String blockNum, String withdrawAmount, String nonce);  }
@Test public void checkWithDrawAmount(){ DelegationValue delegationValue = new DelegationValue(); delegationValue.setFree("234456"); delegationValue.setLock("345"); delegationValue.setMinDelegation("100"); String withdrawAmount = "150"; presenter.setmDelegationValue(delegationValue); presenter.checkWithDrawAmount(withdrawAmount); Mockito.verify(view).showTips(Mockito.anyBoolean(),Mockito.anyString()); }