@Test public void testDelItem() throws Exception { String link = "link"; Item item = new Item(link, "login", "pass"); databaseControl.addItem(item, password); databaseControl.delItem(link, password); try { databaseControl.delItem(link, password); fail("Didn't trigger NoSuchItemException."); } catch (NoSuchItemException nsie) { } Password newPassword = new Password("NewPassword".getBytes()); databaseControl.addItem(item, password); databaseControl.setPassword(password, newPassword); try { databaseControl.delItem(link, password); fail("Didn't trigger InvalidPasswordException!"); } catch (InvalidPasswordException e) { } }
@Test public void testGetItems() throws Exception { Item item1 = new Item("link1", "user1", "pass1"); Item item2 = new Item("link2", "user2", "pass2"); databaseControl.addItem(item1, password); databaseControl.addItem(item2, password); // for (Item item: databaseControl.getItems()){ // databaseControl.delItem(item.getLink(), password); // } databaseControl.getItems().remove(item1); databaseControl.getItems().remove(item2); assertEquals(2, databaseControl.getItems().size()); for (Item item : databaseControl.getItems()) databaseControl.delItem(item.getLink(), password); assertEquals(0, databaseControl.getItems().size()); }