Пример #1
0
 /** Test getting accounts. */
 public final void testGetAccounts() {
   // get a customers account
   Account a1 = null;
   try {
     a1 = bank.getAccount("120-2002");
   } catch (BankException e) {
     e.printStackTrace();
   }
   assertEquals(a1.getType(), "Savings");
   assertEquals(a1.getBalance(), new BigDecimal("150.00"));
   // force exception
   try {
     a1 = bank.getAccount("101-2099");
     fail("getAccount hasn't caused an exception when it should");
   } catch (BankException e) {
     // ignore
   }
   // get all customers accounts
   try {
     List<Account> accounts = bank.getAccounts("120");
     assertEquals(accounts.size(), 2);
     assertEquals(accounts.get(0).getBalance(), new BigDecimal("0"));
     assertEquals(accounts.get(1).getBalance(), new BigDecimal("150.00"));
   } catch (BankException e) {
     e.printStackTrace();
   }
   // force exception
   try {
     List<Account> accounts = bank.getAccounts(null);
     fail("getAccounts hasn't caused an exception when it should");
   } catch (BankException e) {
     // ignore
   }
 } // testGetAccounts
Пример #2
0
 /** Test adding and deleting an account. */
 public final void testAddDeleteAccount() {
   // add account
   try {
     bank.addAccount("120-1111", "120", "C");
   } catch (BankException e) {
     e.printStackTrace();
   }
   // delete account
   try {
     Account a1 = bank.getAccount("120-1111");
     assertNotNull(a1);
     a1 = bank.deleteAccount("120-1111");
     assertNull(a1);
   } catch (BankException e) {
     e.printStackTrace();
   }
   // force exception
   try {
     Account a2 = bank.deleteAccount("120-999");
     // TODO: cause exception
     // fail("deleteAccount hasn't caused an exception as it should");
   } catch (BankException ex) {
     // ignore
   }
 } // testAddDeleteAccount