/** Tests if an added item is contained in the list. */ public void testAdd() { final ItemManager manager = new ItemManager(); final ExpirableItem item = new ExpirableItem(); manager.add(item); final boolean isItemInList = manager.getAllItems().contains(item); assertTrue("The item added cannot be found in the list", isItemInList); }
/** Tests the removal of items. */ public void testRemove() { final ItemManager manager = new ItemManager(); final ExpirableItem item = new ExpirableItem(); manager.add(item); manager.remove(item); final boolean isItemInList = manager.getAllItems().contains(item); assertFalse("The manager still knows the removed item", isItemInList); }
/** Tests replacement of all items. */ public void testReplaceAll() { final ItemManager manager = new ItemManager(); final ExpirableItem oldItem = new ExpirableItem(); manager.add(oldItem); final Collection col = new ArrayList(); final ExpirableItem newItem = new ExpirableItem(); newItem.setName("NewItem"); col.add(newItem); manager.replaceAll(col); assertFalse("Manager still knows old item", manager.getAllItems().contains(oldItem)); assertTrue("Manager does not know new item", manager.getAllItems().contains(newItem)); }