### Question:
WidgetController { @RequestMapping(value = "/admin/widgets", method = RequestMethod.GET) public String viewWidgets(@RequestParam(required = false, defaultValue = "0") int offset, @RequestParam(required = false) final String action, @RequestParam(required = false) String referringPageId, Model model) { model.addAttribute(ModelKeys.REFERRING_PAGE_ID, referringPageId); addNavigationMenusToModel(SELECTED_ITEM, model, referringPageId); final SearchResult<Widget> widgets = widgetService.getLimitedList(offset, getPageSize()); model.addAttribute(ModelKeys.SEARCHRESULT, widgets); if (isDeleteOrUpdate(action)) { model.addAttribute("actionresult", action); } return ViewNames.ADMIN_WIDGETS; }  @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:
@Test public void adminWidgets() throws Exception { Model model = new ExtendedModelMap(); PortalPreferenceService preferenceService = createMock(PortalPreferenceService.class); expect(preferenceService.getPreference(PortalPreferenceKeys.PAGE_SIZE)).andReturn(null); replay(preferenceService); SearchResult<Widget> widgetSearchResult = populateWidgetSearchResult(); expect(service.getLimitedList(DEFAULT_OFFSET, DEFAULT_PAGESIZE)).andReturn(widgetSearchResult); replay(service); String adminWidgetsView = controller.viewWidgets(DEFAULT_OFFSET, null,REFERRER_ID, model); verify(service); assertEquals(ViewNames.ADMIN_WIDGETS, adminWidgetsView); assertEquals(widgetSearchResult, model.asMap().get(ModelKeys.SEARCHRESULT)); assertTrue(model.containsAttribute(TABS)); assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID))); }