Exemplo n.º 1
0
 /** Test getting customers. */
 public final void testGetCustomers() {
   // get single customer
   Customer c1 = null;
   try {
     c1 = bank.getCustomer("120");
   } catch (BankException e) {
     e.printStackTrace();
   }
   assertEquals(c1.getFirstName(), "A");
   assertEquals(c1.getLastName(), "Customer");
   // force exception
   try {
     c1 = bank.getCustomer("201");
     fail("getCustomer hasn't caused an exception when it should");
   } catch (BankException e) {
     // ignore
   }
   // get all customers
   try {
     List<Customer> customers = bank.getCustomers();
     assertEquals(customers.size(), 8); // 6 are in default data set
     assertEquals(customers.get(6).getId(), "120");
     assertEquals(customers.get(7).getId(), "130");
   } catch (BankException e) {
     e.printStackTrace();
   }
 } // testGetCustomers
Exemplo n.º 2
0
 /** Test adding and deleting a customer. */
 public final void testAddDeleteCustomer() {
   // add customer
   try {
     bank.addCustomer("201", "Mr", "New", "Customer");
   } catch (BankException e) {
     e.printStackTrace();
   }
   // delete customer
   try {
     Customer c1 = bank.getCustomer("201");
     assertNotNull(c1);
     c1 = bank.deleteCustomer("201");
     assertNull(c1);
   } catch (BankException e) {
     e.printStackTrace();
   }
   // force exception
   try {
     Customer c2 = bank.deleteCustomer("999");
     // TODO: cause exception
     // fail("deleteCustomer hasn't caused an exception as it should");
   } catch (BankException e) {
     // ignore
   }
 } // testAddDeleteCustomer