### Question:
HeroController { @PostMapping("/hero/new") public String addNewHero(@ModelAttribute("newHero") NewHeroModel newHeroModel) { Hero hero = newHeroModel.getHero(); String repositoryName = newHeroModel.getRepository(); heroService.addHeroToRepository(hero, repositoryName); return "redirect:/hero"; } HeroController(HeroService heroService); @GetMapping("/hero") String viewAllHeros(Model model); @GetMapping("/hero/new") String newHero(Model model); @PostMapping("/hero/new") String addNewHero(@ModelAttribute("newHero") NewHeroModel newHeroModel);  }### Answer:
@Test public void addNewHero() { NewHeroModel model = mock(NewHeroModel.class); when(model.getRepository()).thenReturn(REPOSITORY); when(model.getHero()).thenReturn(new Hero()); String view = subjectUnderTest.addNewHero(model); assertThat(view).isEqualTo("redirect:/hero"); verify(heroService).addHeroToRepository(any(Hero.class), anyString()); }