Inventory { public List<Purchase> purchases() { return Collections.unmodifiableList(purchases); } Inventory(); List<Purchase> purchases(); void addPurchase(Purchase purchase); void addPurchases(Collection<? extends Purchase> purchases); List<Product> products(); void addProduct(Product product); void addProducts(Collection<? extends Product> products);  }
@Test(expected = UnsupportedOperationException.class) public void returnsImmutablePurchaseList() { final Inventory inventory = new Inventory(); final List<Purchase> purchases = inventory.purchases(); purchases.add(ValueFactory.aPurchase()); }