### Question:
PortalPreferenceController { @RequestMapping(value = "/admin/preferencedetail/edit", method = RequestMethod.GET) public String editPreferences(Model model, @RequestParam(required = false) String referringPageId) { model.addAttribute(ModelKeys.REFERRING_PAGE_ID, referringPageId); addNavigationMenusToModel(SELECTED_ITEM, model, referringPageId); final Map<String, PortalPreference> preferenceMap = preferenceService.getPreferencesAsMap(); PortalPreferenceForm form = new PortalPreferenceForm(preferenceMap); model.addAttribute("preferenceForm", form); model.addAttribute(ModelKeys.TOKENCHECK, AdminControllerUtil.generateSessionToken()); return ViewNames.ADMIN_PREFERENCE_DETAIL; }  @RequestMapping(value = {"/admin/preferences", "/admin/preferences/"}, method = RequestMethod.GET) String viewPreferences(@RequestParam(required = false) final String action,
                                  @RequestParam(required = false) String referringPageId,Model model); @RequestMapping(value = "/admin/preferencedetail/edit", method = RequestMethod.GET) String editPreferences(Model model, @RequestParam(required = false) String referringPageId); @RequestMapping(value = "/admin/preferencedetail/update", method = RequestMethod.POST) String updatePreferences(@ModelAttribute("preferenceForm") PortalPreferenceForm form, BindingResult result,
                                    @ModelAttribute(ModelKeys.TOKENCHECK) String sessionToken,
                                    @RequestParam String token,
                                    @RequestParam(required = false) String referringPageId,
                                    ModelMap modelMap,
                                    SessionStatus status); void setPreferenceService(PortalPreferenceService preferenceService);  }### Answer:
@Test public void testEditPreferences() { Model model = new ExtendedModelMap(); Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>(); expect(service.getPreferencesAsMap()).andReturn(preferenceMap); replay(service); String view = controller.editPreferences(model,REFERRER_ID); assertEquals(ViewNames.ADMIN_PREFERENCE_DETAIL, view); assertTrue(model.asMap().get("preferenceForm") instanceof PortalPreferenceForm); assertTrue(model.containsAttribute(ModelKeys.TOKENCHECK)); assertTrue(model.containsAttribute("topnav")); assertTrue(model.containsAttribute("tabs")); assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID))); }