@Test public void updateList() { emptyRepository.createList(groceryList); groceryList.setSettled(true); groceryList.setShoppingItems(new Item[] { ITEM_SOY_MILK }); assertTrue(emptyRepository.updateList(groceryList.getId(), groceryList)); Optional<GroceryList> updatedList = emptyRepository.getList(groceryList.getId()); assertTrue(updatedList.isPresent()); assertEquals(1, updatedList.get().getShoppingItems().length); assertEquals("soy milk", updatedList.get().getShoppingItems()[0].getName()); }
public boolean updateList(UUID uuid, GroceryList updatedList) { updatedList.setId(uuid); groceryLists.replaceAll(list -> uuid.equals(list.getId()) ? updatedList : list); save(); return groceryLists.contains(updatedList); }
Repository { public boolean updateList(UUID uuid, GroceryList updatedList) { updatedList.setId(uuid); groceryLists.replaceAll(list -> uuid.equals(list.getId()) ? updatedList : list); save(); return groceryLists.contains(updatedList); } }
Repository { public boolean updateList(UUID uuid, GroceryList updatedList) { updatedList.setId(uuid); groceryLists.replaceAll(list -> uuid.equals(list.getId()) ? updatedList : list); save(); return groceryLists.contains(updatedList); } @Inject  Repository(@Named("datastore") File dataFile, ModelSerializer serializer); }
Repository { public boolean updateList(UUID uuid, GroceryList updatedList) { updatedList.setId(uuid); groceryLists.replaceAll(list -> uuid.equals(list.getId()) ? updatedList : list); save(); return groceryLists.contains(updatedList); } @Inject  Repository(@Named("datastore") File dataFile, ModelSerializer serializer); UUID createList(GroceryList groceryList); Optional<GroceryList> getList(UUID id); GroceryLists getLists(); boolean updateList(UUID uuid, GroceryList updatedList); boolean deleteList(UUID uuid); }
Repository { public boolean updateList(UUID uuid, GroceryList updatedList) { updatedList.setId(uuid); groceryLists.replaceAll(list -> uuid.equals(list.getId()) ? updatedList : list); save(); return groceryLists.contains(updatedList); } @Inject  Repository(@Named("datastore") File dataFile, ModelSerializer serializer); UUID createList(GroceryList groceryList); Optional<GroceryList> getList(UUID id); GroceryLists getLists(); boolean updateList(UUID uuid, GroceryList updatedList); boolean deleteList(UUID uuid);  }