### Question:
TodoController { @PutMapping("/users/{name}/todos/{id}") public ResponseEntity<Todo> updateTodo(@PathVariable String name, @PathVariable int id, @RequestBody Todo todo) { System.out.println(todo); todoService.update(todo); return new ResponseEntity<Todo>(todo, HttpStatus.OK); }  @ApiOperation(value = "Retrieve all todos for a user by passing in his name", notes = "A list of matching todos is returned. Currently pagination is not supported.", response = Todo.class, responseContainer = "List", produces = "application/json") @GetMapping("/users/{name}/todos") List<Todo> retrieveTodos(@PathVariable String name); @GetMapping(path = "/users/{name}/todos/{id}") Resource<Todo> retrieveTodo(@PathVariable String name, @PathVariable int id); @DeleteMapping("/users/{name}/todos/{id}") ResponseEntity<Void> deleteTodo(@PathVariable String name, @PathVariable int id); @PutMapping("/users/{name}/todos/{id}") ResponseEntity<Todo> updateTodo(@PathVariable String name, @PathVariable int id, @RequestBody Todo todo); @GetMapping(path = "/users/dummy-service") Todo errorService();  }### Answer:
@Test public void updateTodo() throws Exception { Todo mockTodo = new Todo(UPDATED_TODO_ID, "Jack", "Learn Spring MVC 5", new Date(), false); String todo = "{\"user\":\"Jack\",\"desc\":\"Learn Spring MVC 5\",\"done\":false}"; when(service.update(mockTodo)).thenReturn(mockTodo); MvcResult result = mvc.perform(MockMvcRequestBuilders.put("/users/Jack/todos/" + UPDATED_TODO_ID).content(todo) .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andReturn(); JSONAssert.assertEquals(todo, result.getResponse().getContentAsString(), false); }