@Test public void testUpdate() { accVec = new AccountVector(); try { OrdinaryAccount acc1 = new OrdinaryAccount("670"); accVec.create(acc1); acc1.credit(200); accVec.update(acc1); assertEquals(acc1.getBalance(), accVec.retrieve("670").getBalance(), 0); } catch (AccountCreationException e) { System.out.println("Should not enter this catch block"); } catch (NegativeAmountException e) { System.out.println("nor this"); } catch (AccountNotFoundException e) { System.out.println("or this"); } }
@Test(expected = AccountNotFoundException.class) public void testUpdateNonExistingAccount() throws AccountNotFoundException { accVec = new AccountVector(); accVec.update(new SpecialAccount("50")); }