### Question:
WidgetController { @RequestMapping(value = "/admin/widgetdetail/{widgetid}", method = RequestMethod.GET) public String viewWidgetDetail(@PathVariable("widgetid") String widgetid, @RequestParam(required = false) String referringPageId,Model model) { addNavigationMenusToModel(SELECTED_ITEM, model, referringPageId); model.addAttribute(ModelKeys.REFERRING_PAGE_ID, referringPageId); model.addAttribute(ModelKeys.WIDGET, widgetService.getWidget(widgetid)); model.addAttribute(ModelKeys.TOKENCHECK, AdminControllerUtil.generateSessionToken()); model.addAttribute(ModelKeys.CATEGORIES, categoryService.getAllList()); return ViewNames.ADMIN_WIDGETDETAIL; }  @InitBinder void initBinder(WebDataBinder dataBinder); @RequestMapping(value = "/admin/widgets", method = RequestMethod.GET) String viewWidgets(@RequestParam(required = false, defaultValue = "0") int offset,
                              @RequestParam(required = false) final String action,
                              @RequestParam(required = false) String referringPageId,
                              Model model); @RequestMapping(value = "/admin/widgets/search", method = RequestMethod.GET) String searchWidgets(@RequestParam(required = false) String searchTerm,
                                @RequestParam(required = false) String widgettype,
                                @RequestParam(required = false) String widgetstatus,
                                @RequestParam(required = false, defaultValue = "0") int offset,
                                @RequestParam(required = false) String referringPageId, Model model); @RequestMapping(value = "/admin/widgetdetail/{widgetid}", method = RequestMethod.GET) String viewWidgetDetail(@PathVariable("widgetid") String widgetid,
                                   @RequestParam(required = false) String referringPageId,Model model); @RequestMapping(value = "/admin/widgetdetail/update", method = RequestMethod.POST) String updateWidgetDetail(@ModelAttribute(ModelKeys.WIDGET) Widget widget, BindingResult result,
                                     @ModelAttribute(ModelKeys.TOKENCHECK) String sessionToken,
                                     @RequestParam String token,
                                     @RequestParam(required = false) String referringPageId,
                                     ModelMap modelMap,
                                     SessionStatus status); @ModelAttribute("widgetStatus") WidgetStatus[] getWidgetStatusValues(); void setPreferenceService(PortalPreferenceService preferenceService); void setCategoryService(CategoryService categoryService); void setCategoryEditor(CategoryEditor categoryEditor); int getPageSize();  }### Answer:
@SuppressWarnings("unchecked") @Test public void viewAdminWidgetDetail() throws Exception { Model model = new ExtendedModelMap(); WidgetImpl widget = new WidgetImpl(); final String entityId = "123"; widget.setId(entityId); widget.setTitle("My widget"); expect(service.getWidget(entityId)).andReturn(widget); expect(categoryService.getAllList()).andReturn(categories); replay(service, categoryService); String adminWidgetDetailView = controller.viewWidgetDetail(entityId,REFERRER_ID, model); verify(service, categoryService); assertEquals(ViewNames.ADMIN_WIDGETDETAIL, adminWidgetDetailView); assertTrue(model.containsAttribute(TABS)); assertEquals(widget, model.asMap().get("widget")); assertThat(model.containsAttribute(ModelKeys.CATEGORIES), is(true)); assertThat((List<Category>) model.asMap().get(ModelKeys.CATEGORIES), is(categories)); assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID))); }