### Question:
SectionController { @RequestMapping(value = "/sections/{sectionId}", method = RequestMethod.GET) public ModelAndView branchList(@PathVariable("sectionId") long sectionId) throws AccessDeniedException, NotFoundException { Section section = sectionService.get(sectionId); sectionService.ifSectionIsVisible(section); sectionService.prepareSectionsForView(Arrays.asList(section)); return new ModelAndView("branchList") .addObject("viewList", locationService.getUsersViewing(section)) .addObject("section", section); } @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 testBranchesInSection() throws NotFoundException { long sectionId = 1L; Section section = new Section("section name"); section.setId(sectionId); when(sectionService.get(sectionId)).thenReturn(section); doNothing().when(sectionService).ifSectionIsVisible(section); when(breadcrumbBuilder.getForumBreadcrumb()).thenReturn(new ArrayList<Breadcrumb>()); ModelAndView mav = controller.branchList(sectionId); verify(sectionService).get(sectionId); assertViewName(mav, "branchList"); assertModelAttributeAvailable(mav, "section"); Section actualSection = assertAndReturnModelAttributeOfType(mav, "section", Section.class); assertEquals(actualSection.getId(), sectionId); }
@Test public void testViewList() throws NotFoundException { long sectionId = 1L; Section section = new Section("section name"); section.setId(sectionId); when(sectionService.get(sectionId)).thenReturn(section); when(breadcrumbBuilder.getForumBreadcrumb()).thenReturn(new ArrayList<Breadcrumb>()); ModelAndView mav = controller.branchList(sectionId); assertModelAttributeAvailable(mav, "viewList"); List<String> actualViewList = assertAndReturnModelAttributeOfType(mav, "viewList", List.class); assertEquals(actualViewList, new ArrayList<String>()); }