package jbossaop.testing.bank;

import jbossaop.testing.customer.*;

public final class BankBusiness
{
   private final BankAccountDAO bankAccountDAO;

   public BankBusiness()
   {
      // Note that this dependency could be obtained by directly instantiating a DAO implementation,
      // and it still could be easily unit tested with JMockit. Therefore, if enabling unit testing
      // was the only reason to have the DAO interfaces and the DAO factories, the application
      // architecture could be significantly simplified by getting rid of them all, and using
      // concrete DAO implementation classes. Or even better, consider NOT using entity-specific
      // DAOs at all, instead simply using JPA or another ORM API directly or (preferentially) from
      // behind a static facade.
      bankAccountDAO = BankAccountDAOFactory.getBankAccountDAOSerializer();
   }

   public boolean creditCheck(Customer c, double amount)
   {
      return getSumOfAllAccounts(c) < amount * 0.4;
   }

   public double calculateInterest(BankAccount account)
   {
      int balance = account.getBalance();

      if (balance < 1000) {
         return 0.01;
      }
      else if (balance < 10000) {
         return 0.02;
      }
      else if (balance < 100000) {
         return 0.03;
      }
      else if (balance < 1000000) {
         return 0.05;
      }
      else {
         return 0.06;
      }
   }

   public double getSumOfAllAccounts(Customer c)
   {
      double sum = 0;

      for (long accountNo : c.getAccounts()) {
         BankAccount a = bankAccountDAO.getBankAccount(accountNo);

         if (a != null) {
            sum += a.getBalance();
         }
      }

      return sum;
   }
}

@@ -901,560 +901,8 @@
 %0D%0A%0D%0A
-   public boolean creditCheck(Customer c, double amount)%0D%0A   %7B%0D%0A      return getSumOfAllAccounts(c) %3C amount * 0.4;%0D%0A   %7D%0D%0A%0D%0A   public double calculateInterest(BankAccount account)%0D%0A   %7B%0D%0A      int balance = account.getBalance();%0D%0A%0D%0A      if (balance %3C 1000) %7B%0D%0A         return 0.01;%0D%0A      %7D%0D%0A      else if (balance %3C 10000) %7B%0D%0A         return 0.02;%0D%0A      %7D%0D%0A      else if (balance %3C 100000) %7B%0D%0A         return 0.03;%0D%0A      %7D%0D%0A      else if (balance %3C 1000000) %7B%0D%0A         return 0.05;%0D%0A      %7D%0D%0A      else %7B%0D%0A         return 0.06;%0D%0A      %7D%0D%0A   %7D%0D%0A%0D%0A
    p

Removed two unused and untested business methods.