@Test(expected = AccountCreationException.class) public void testCreateExistingAccount() throws AccountCreationException { accVec.create(new OrdinaryAccount("200")); accVec.create(new OrdinaryAccount("200")); try { accVec.delete("200"); } catch (AccountDeletionException e) { System.out.println( "Should not enter this catch block once we make sure the account is created"); } }
@Test public void testDelete() { try { accVec.create(new OrdinaryAccount("200")); assertEquals(1, accVec.numberOfAccounts(), 0); accVec.delete("200"); assertEquals(0, accVec.numberOfAccounts(), 0); } catch (AccountCreationException acex) { System.out.println("Should not enter this catch block"); } catch (AccountDeletionException adex) { System.out.println("Should not enter this catch block either"); } }
@Test public void testNumberOfAccounts() { try { accVec.delete("200"); } catch (AccountDeletionException ade) { } finally { assertEquals(0, accVec.numberOfAccounts(), 0); } try { accVec.create(new OrdinaryAccount("300")); assertEquals(1, accVec.numberOfAccounts(), 0); } catch (AccountCreationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Test(expected = AccountDeletionException.class) public void testDeleteWithoutAccount() throws AccountDeletionException { accVec.delete("3"); }