Package org.jtalks.common.model.entity

Examples of org.jtalks.common.model.entity.Section


     *
     * @param branch {@link org.jtalks.jcommune.model.entity.Branch} the breadcrumbed branch.
     * @return {@link Breadcrumb} the filled breadcrumb for the Section location.
     */
    private Breadcrumb prepareBranchBreadcrumb(Branch branch) {
        Section section = branch.getSection();
        return new Breadcrumb(
                section.getId(),
                BreadcrumbLocation.SECTION,
                section.getName());
    }
View Full Code Here


    }

    @Test
    public void testBranchesInSection() throws NotFoundException {
        long sectionId = 1L;
        Section section = new Section("section name");
        section.setId(sectionId);

        //set expectations
        when(sectionService.get(sectionId)).thenReturn(section);
        doNothing().when(sectionService).ifSectionIsVisible(section);
        when(breadcrumbBuilder.getForumBreadcrumb()).thenReturn(new ArrayList<Breadcrumb>());

        //invoke the object under test
        ModelAndView mav = controller.branchList(sectionId);

        //check expectations
        verify(sectionService).get(sectionId);
        //check result
        assertViewName(mav, "branchList");
        assertModelAttributeAvailable(mav, "section");
        Section actualSection = assertAndReturnModelAttributeOfType(mav, "section", Section.class);
        assertEquals(actualSection.getId(), sectionId);
    }
View Full Code Here

    }

    @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);
View Full Code Here

    @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());
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public Section deleteAllTopicsInSection(long sectionId) throws NotFoundException {
        Section section = get(sectionId);

        //Create tmp list to avoid ConcurrentModificationException
        List<Branch> loopList = new ArrayList<>(section.getBranches());
        for (Branch branch : loopList) {
            branchService.deleteAllTopics(branch.getId());
        }

        logger.info("All branches for sections \"{}\" were deleted. " +
                "Section id: {}", section.getName(), section.getId());
        return section;
    }
View Full Code Here

    public void setUp() throws Exception {
        breadcrumbBuilder = new BreadcrumbBuilder();

        JCUser user = new JCUser("user", "mail@mail.com", "password");

        section = new Section("Section Name");
        section.setId(ID);

        branch = new Branch("Branch Name", "Branch description");
        branch.setId(ID);
        section.addOrUpdateBranch(branch);
View Full Code Here

     * @throws AccessDeniedException when denied access a section
     */
    @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);
View Full Code Here

     *
     * @return {@code ModelAndView} with post list and vars for pagination
     */
    @RequestMapping("/sections/{sectionId}/recent")
    public ModelAndView recentBranchPostsPage(@PathVariable("sectionId") long sectionId) throws NotFoundException {
        Section section = sectionService.get(sectionId);
        sectionService.ifSectionIsVisible(section);

        List<Post> posts = sectionService.getLastPostsForSection(section, RECENT_POST_COUNT);

        return new ModelAndView("sections/recent")
                .addObject("feedTitle", section.getName())
                .addObject("feedDescription", section.getDescription())
                .addObject("urlSuffix", "/sections/" + section.getId())
                .addObject("posts", posts);

    }
View Full Code Here

    public List<Branch> getAvailableBranchesInSection(long sectionId, long currentTopicId) throws NotFoundException {
        if (!sectionDao.isExist(sectionId)) {
            throw new NotFoundException("Section with id: " + sectionId + " not found");
        }

        Section section = sectionDao.get(sectionId);
        List<Branch> branches = (List) section.getBranches();
        return getBranchesWithViewPermission(currentTopicId, branches);
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    @PreAuthorize("hasPermission(#componentId, 'COMPONENT', 'GeneralPermission.ADMIN')")
    public void createNewBranch(long componentId, long sectionId, String title, String description) {
        Section section = sectionDao.get(sectionId);
        Branch branch = new Branch(title, description);
        branch.setSection(section);
        section.addOrUpdateBranch(branch);
        sectionDao.saveOrUpdate(section);
        //add default permission to view topics (for group Registered users)
        Group registeredUsersGroup = groupDao.getGroupByName(AdministrationGroup.USER.getName());
        Collection<Group> groups = Arrays.asList(registeredUsersGroup);
        PermissionChanges permissionChanges = new PermissionChanges(BranchPermission.VIEW_TOPICS, groups,
View Full Code Here

TOP

Related Classes of org.jtalks.common.model.entity.Section

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.