### Question:
ToDoController { @RequestMapping(value="/items/{id}", method = RequestMethod.DELETE) public ResponseEntity<String> deleteItem(@PathVariable("id") long id) { try { toDoItemDao.delete(id); return new ResponseEntity<>(HttpStatus.OK); } catch (DaoException ex) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }  @RequestMapping(value="/items", method = RequestMethod.GET) @ResponseBody String getAll(ModelMap model); @RequestMapping(value="/items", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody ToDoItem addItem(@RequestBody final ToDoItem item); @RequestMapping(value="/items/{id}", method = RequestMethod.DELETE) ResponseEntity<String> deleteItem(@PathVariable("id") long id); @RequestMapping(value="/items", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody ToDoItem updateItem(@RequestBody final ToDoItem item); void setToDoItemDao(ToDoItemDao toDoItemDao);  }### Answer:
@Test public void deleteItem() { long idToRemove = 123; ResponseEntity<String> result = controller.deleteItem(123); verify(dao).delete(idToRemove); assertEquals(result.getStatusCode(), HttpStatus.OK); }
@Test public void deleteNonExistingItemShouldCauseException() { long idToRemove = 123; Mockito.doThrow(new DaoException()).when(dao).delete(idToRemove); ResponseEntity<String> result = controller.deleteItem(123); verify(dao).delete(idToRemove); assertEquals(result.getStatusCode(), HttpStatus.NOT_FOUND); }