FileDocCategorySizeDatePackage
MakeDeposit.javaAPI DocExample1630Thu Nov 08 00:22:50 GMT 2001com.ora.rmibook.chapter13.bank.applications.tests

MakeDeposit

public class MakeDeposit extends Test

Fields Summary
Constructors Summary
public MakeDeposit(NameRepository nameRepository)

        super (nameRepository);
    
Methods Summary
protected java.lang.StringdescribeOperation()

        return "make a deposit to ";
    
protected java.lang.StringperformActualTest(java.lang.String idNumber, Account3 account)

        Money balance;
        Money amountToDeposit = getRandomMoney();
        Money correctResult;
        Money actualResultingBalance;

        try {
            balance = account.getBalance(idNumber);
            correctResult = balance.add(amountToDeposit);
            account.makeDeposit(idNumber, amountToDeposit);
            actualResultingBalance = account.getBalance(idNumber);
        } catch (RemoteException remoteException) {
            return REMOTE_EXCEPTION_THROWN;
        } catch (LockedAccountException lockedAccountException) {
            return ACCOUNT_WAS_LOCKED;
        } catch (NegativeAmountException negativeAmountException) {
            if (amountToDeposit.isNegative()) {
                return SUCCESS;
            } else {
                return FAILURE;
            }
        }
        if (amountToDeposit.isNegative()) {
            return FAILURE;
        }
        if (correctResult.equals(actualResultingBalance)) {
            return SUCCESS;
        } else {
            return FAILURE;
        }