### Question:
TodoController { @GetMapping(path = "/users/{name}/todos/{id}") public Todo retrieveTodo(@PathVariable String name, @PathVariable int id) { return todoService.retrieveTodo(id); }  @GetMapping("/users/{name}/todos") List<Todo> retrieveTodos(@PathVariable String name); @GetMapping(path = "/users/{name}/todos/{id}") Todo retrieveTodo(@PathVariable String name, @PathVariable int id);  }### Answer:
@Test public void retrieveTodo() throws Exception { Todo mockTodo = new Todo(1, "Jack", "Learn Spring MVC", new Date(), false); when(service.retrieveTodo(anyInt())).thenReturn(mockTodo); MvcResult result = mvc .perform(MockMvcRequestBuilders.get("/users/Jack/todos/1").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn(); String expected = "{id:1,user:Jack,desc:\"Learn Spring MVC\",done:false}"; JSONAssert.assertEquals(expected, result.getResponse().getContentAsString(), false); }