### Question:
SectionController { @RequestMapping(value = {"/", "/sections"}, method = RequestMethod.GET) public ModelAndView sectionList(HttpSession session) { session.getId(); List<Section> sections = sectionService.getAll(); sectionService.prepareSectionsForView(sections); return new ModelAndView("sectionList") .addObject("sectionList", sections) .addObject("messagesCount", forumStaticsProvider.getPostsOnForumCount()) .addObject("registeredUsersCount", forumStaticsProvider.getUsersCount()) .addObject("visitors", forumStaticsProvider.getOnlineUsersCount()) .addObject("usersRegistered", forumStaticsProvider.getOnlineRegisteredUsers()) .addObject("visitorsRegistered", forumStaticsProvider.getOnlineRegisteredUsersCount()) .addObject("visitorsGuests", forumStaticsProvider.getOnlineAnonymousUsersCount()); } @Autowired  SectionController(SectionService sectionService,
                             ForumStatisticsProvider forumStaticsProvider,
                             LocationService locationService); @RequestMapping(value = {"/", "/sections"}, method = RequestMethod.GET) ModelAndView sectionList(HttpSession session); @RequestMapping(value = "/sections/json/{currentTopicId}", method = RequestMethod.GET) @ResponseBody SectionDto[] sectionList(@PathVariable("currentTopicId") long currentTopicId); @RequestMapping(value = "/sections/{sectionId}", method = RequestMethod.GET) ModelAndView branchList(@PathVariable("sectionId") long sectionId); @RequestMapping("/sections/{sectionId}/recent") ModelAndView recentBranchPostsPage(@PathVariable("sectionId") long sectionId);  }### Answer:
@Test public void testDisplayAllSections() { when(sectionService.getAll()).thenReturn(new ArrayList<Section>()); ModelAndView mav = controller.sectionList(mock(HttpSession.class)); verifyAndAssertAllSections(mav); }
@Test public void testSectionList() { List<Section> sections = new ArrayList<>(); long sectionId = 1L; long topicId = 1L; Section section = new Section("section name"); section.setId(sectionId); sections.add(section); when(sectionService.getAllAvailableSections(topicId)).thenReturn(sections); SectionDto[] sectionDtoArray = controller.sectionList(topicId); assertEquals(sectionDtoArray.length, sections.size()); assertEquals(sectionDtoArray[0].getId(), section.getId()); assertEquals(sectionDtoArray[0].getName(), section.getName()); }