### Question:
WidgetStoreController { @RequestMapping(method = RequestMethod.GET) public String view(Model model, @RequestParam String referringPageId, @RequestParam(required = false, defaultValue = "0") int offset) { final String view = ViewNames.STORE; User user = userService.getAuthenticatedUser(); widgetStoreModelHelper(model, referringPageId, user, view); model.addAttribute(ModelKeys.WIDGETS, widgetService.getPublishedWidgets(offset, getPageSize())); return view; } @Autowired  WidgetStoreController(WidgetService widgetService, NewWidgetValidator validator, UserService userService,
            PortalPreferenceService preferenceService, TagService tagService, CategoryService categoryService); @RequestMapping(method = RequestMethod.GET) String view(Model model, @RequestParam String referringPageId,
            @RequestParam(required = false, defaultValue = "0") int offset); @RequestMapping(method = RequestMethod.GET, value = "mine") String viewMine(Model model, @RequestParam String referringPageId,
            @RequestParam(required = false, defaultValue = "0") int offset); @RequestMapping(method = RequestMethod.GET, value = "widget/{widgetId}") String viewWidget(Model model, @PathVariable String widgetId, @RequestParam String referringPageId); @RequestMapping(method = RequestMethod.GET, value = "search") String viewSearchResult(Model model, @RequestParam String referringPageId, @RequestParam String searchTerm,
            @RequestParam(required = false, defaultValue = "0") int offset); @RequestMapping(method = RequestMethod.GET, value = "tag") String viewTagResult(Model model, @RequestParam String referringPageId, @RequestParam String keyword,
            @RequestParam(required = false, defaultValue = "0") int offset); @RequestMapping(method = RequestMethod.GET, value = "category") String viewCategoryResult(@RequestParam(required = true) String referringPageId,
            @RequestParam(required = true) String categoryId,
            @RequestParam(required = false, defaultValue = "0") int offset, Model model); @RequestMapping(method = RequestMethod.GET, value = "widget/add") String viewAddWidgetForm(Model model, @RequestParam String referringPageId); @RequestMapping(method = RequestMethod.GET, value = "widget/add/{type}") String viewAddWidgetFormByType(Model model, @RequestParam String referringPageId, @PathVariable String type); @RequestMapping(method = RequestMethod.POST, value = "widget/add") String viewAddWidgetResult(@ModelAttribute WidgetImpl widget, BindingResult results, Model model,
            @RequestParam String referringPageId); @RequestMapping(method = RequestMethod.POST, value = "widget/add/w3c") String viewAddWidgetResultW3c(@ModelAttribute WidgetImpl widget, BindingResult results, Model model,
            @RequestParam String referringPageId); int getPageSize();  }### Answer:
@Test @SuppressWarnings("unchecked") public void view() { Model model = new ExtendedModelMap(); List<Widget> widgets = new ArrayList<Widget>(); SearchResult<Widget> emptyResult = new SearchResult<Widget>(widgets, 0); expect(widgetService.getPublishedWidgets(0, 10)).andReturn(emptyResult); expect(widgetService.getAllWidgetStatistics(validUser.getId())).andReturn(allWidgetStatisticsMap); replay(widgetService); String view = controller.view(model, REFERRER_ID, 0); verify(widgetService); assertThat(view, is(equalTo(ViewNames.STORE))); assertThat(model.containsAttribute(ModelKeys.WIDGETS), is(true)); assertThat(model.containsAttribute(ModelKeys.WIDGETS_STATISTICS), is(true)); assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID))); assertThat(widgets, is(sameInstance(emptyResult.getResultSet()))); assertThat(model.containsAttribute(ModelKeys.TAGS), is(true)); assertThat(model.containsAttribute(ModelKeys.CATEGORIES), is(true)); }