TreasureChest { public List<Item> getItems() { List<Item> list = new ArrayList<>(); list.addAll(items); return list; } TreasureChest(); List<Item> getItems();  }
@Test public void testGetItems() throws Exception { final TreasureChest chest = new TreasureChest(); final List<Item> items = chest.getItems(); assertNotNull(items); for (final Item item : items) { assertNotNull(item); assertNotNull(item.getType()); assertNotNull(item.toString()); final boolean sameType = this.expectedItem.getType() == item.getType(); final boolean sameName = this.expectedItem.toString().equals(item.toString()); if (sameType && sameName) { return; } } fail("Expected to find item [" + this.expectedItem + "] in the item list, but we didn't."); }