### Question:
CommentsController { @RequestMapping(method = RequestMethod.GET) public void setupForm(ModelMap modelMap, HttpServletRequest request) { String sessionId = request.getParameter("sessionId"); try { long lSessionId = Long.valueOf(sessionId); Session session = sessionDao.getSessionById(sessionId); modelMap.put("sessionId", sessionId); modelMap.put("comments", commentDao.getCommentsBySessionId(lSessionId)); modelMap.put("session", session); modelMap.put("links", linkDao.getLinksBySessionId(lSessionId)); modelMap.put("sessionEditable", getSessionIsEditable(session.getType().getLabel())); String location = session.getLocation() != null ? session.getLocation() : "Unknown"; String author = session.getAuthor() != null ? session.getAuthor() : "Unknown"; modelMap.put("location", location); modelMap.put("sessionSpeaker", TwitterLinkCreator.process(author)); } catch (Exception e) { modelMap.put("comments", ""); modelMap.put("sessionTitle", "Nice try :)"); modelMap.put("sessionDescription", "Do you think this is something a normal user would do?"); } }  @RequestMapping(method = RequestMethod.GET) void setupForm(ModelMap modelMap, HttpServletRequest request);  }### Answer:
@Test public void testSetupForm() throws Exception { String title = "title"; String sessionId = "42"; Long sessionIdLong = Long.valueOf(sessionId); String location = "location"; Session session = new Session("date", "startTime", location, title, "author", "description"); session.setType(SessionType.session); Comment comment = new Comment(new Date(), "author", "text", sessionIdLong); List<Comment> comments = Arrays.asList(comment); Link link = new Link(new Date(), "comment", "http: List<Link> links = Arrays.asList(link); when(sessionDao.getSessionById(sessionId)).thenReturn(session); when(commentDao.getCommentsBySessionId(sessionIdLong)).thenReturn(comments); when(linkDao.getLinksBySessionId(sessionIdLong)).thenReturn(links); mockMvc.perform(get("/comments").param("sessionId", sessionId)).andExpect(status().isOk()).andExpect(model().attributeExists("comments")).andExpect(model().attribute("session", session)) .andExpect(model().attribute("location", containsString(location))).andExpect(view().name("comments")); }