### Question:
PluginController { @RequestMapping(value = "/configure/{name}", method = RequestMethod.POST) public ModelAndView updateConfiguration(Model model, @ModelAttribute PluginConfiguration newConfiguration) throws NotFoundException { long componentId = getForumComponentId(); try { pluginService.updateConfiguration(newConfiguration, componentId); } catch (UnexpectedErrorException ex) { model.addAttribute("error", ex.getCause().getLocalizedMessage()); model.addAttribute("errorInformation", ExceptionUtils.getFullStackTrace(ex.getCause())); model.addAttribute("pluginConfiguration", newConfiguration); return getModel(newConfiguration); } return new ModelAndView("redirect:/plugins/configure/" + newConfiguration.getName()); } @Autowired  PluginController(PluginService pluginService, ComponentService componentService, PluginLoader pluginLoader,
                            UserService userService); @RequestMapping(value = "/list", method = RequestMethod.GET) ModelAndView getPlugins(); @RequestMapping(value = "/configure/{name}", method = RequestMethod.GET) ModelAndView startConfiguringPlugin(@PathVariable String name); @RequestMapping(value = "/configure/{name}", method = RequestMethod.POST) ModelAndView updateConfiguration(Model model, @ModelAttribute PluginConfiguration newConfiguration); @RequestMapping(value = "/activate", method = RequestMethod.POST) @ResponseBody JsonResponse activatePlugin(@RequestBody PluginActivatingDto pluginActivatingDto);  }### Answer:
@Test public void updateConfigurationShouldUpdateItByCallingServiceLayer() throws NotFoundException, UnexpectedErrorException { long componentId = 25L; Component component = new Component(); component.setId(componentId); when(componentService.getComponentOfForum()).thenReturn(component); String pluginName = "plugin"; PluginConfiguration newConfiguration = new PluginConfiguration(); newConfiguration.setName(pluginName); Model model = new ExtendedModelMap(); ModelAndView mav = pluginController.updateConfiguration(model, newConfiguration); assertViewName(mav, "redirect:/plugins/configure/" + pluginName); verify(pluginService).updateConfiguration(newConfiguration, componentId); }
@Test public void updateConfigurationShouldReturnConfigurationPageWithErrorWhenConfigurationWasFailed() throws NotFoundException, UnexpectedErrorException { PluginConfiguration newConfiguration = createFailingConfiguration(); Model model = new ExtendedModelMap(); ModelAndView mav = pluginController.updateConfiguration(model, newConfiguration); assertViewName(mav, "plugin/pluginConfiguration"); assertTrue(model.containsAttribute("pluginConfiguration")); }