### Question:
PersonController { @RequestMapping(value = "/{id:[\\d]*}", method = RequestMethod.GET) public String show(@PathVariable Long id, Model model) throws NotFoundException { Optional<Person> personOpt = personService.findById(id); if(personOpt.isPresent()) { model.addAttribute("person", personOpt.get()); } else { throw new NotFoundException(Person.class, id); } return "persons/show"; } PersonController(PersonService personService); @GetMapping(value = "/list") String list(Model model); @RequestMapping(value = "/{id:[\\d]*}", method = RequestMethod.GET) String show(@PathVariable Long id, Model model);  }### Answer:
@Test void testShowHandler() throws NotFoundException { Person p = new Person(); p.setId(1L); when(mockService.findById(any(Long.class))).thenReturn(Optional.of(p)); ExtendedModelMap model = new ExtendedModelMap(); String viewName = personController.show(1L, model); Person person = (Person) model.get("person"); assertAll( () -> assertNotNull(person), () -> assertEquals(1L, person.getId()), () -> assertEquals("persons/show", viewName) ); }