Examples of addOrUpdateBranch()


Examples of org.jtalks.common.model.entity.Section.addOrUpdateBranch()

    @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

Examples of org.jtalks.common.model.entity.Section.addOrUpdateBranch()

    }
   
    @Test
    public void testDeleteAllBranches() throws NotFoundException {
        Section expectedSection = new Section(SECTION_NAME);
        expectedSection.addOrUpdateBranch(new Branch(null, null));
        expectedSection.addOrUpdateBranch(new Branch(null, null));
       
        when(sectionDao.isExist(SECTION_ID)).thenReturn(true);
        when(sectionDao.get(SECTION_ID)).thenReturn(expectedSection);
       
View Full Code Here

Examples of org.jtalks.common.model.entity.Section.addOrUpdateBranch()

   
    @Test
    public void testDeleteAllBranches() throws NotFoundException {
        Section expectedSection = new Section(SECTION_NAME);
        expectedSection.addOrUpdateBranch(new Branch(null, null));
        expectedSection.addOrUpdateBranch(new Branch(null, null));
       
        when(sectionDao.isExist(SECTION_ID)).thenReturn(true);
        when(sectionDao.get(SECTION_ID)).thenReturn(expectedSection);
       
        Section actualSection = sectionService.deleteAllTopicsInSection(SECTION_ID);
View Full Code Here

Examples of org.jtalks.common.model.entity.Section.addOrUpdateBranch()

        Section section = new Section(SECTION_NAME);
        Branch branch1 = new Branch("my branch", "1");
        branch1.setId(42);
        Branch branch2 = new Branch("my branch2", "2");
        branch2.setId(43);
        section.addOrUpdateBranch(branch1);
        section.addOrUpdateBranch(branch2);
        when(userService.getCurrentUser()).thenReturn(user);
        List<Long> branchIds = Arrays.asList(branch1.getId());
        when(sectionDao.getAvailableBranchIds(user, section.getBranches())).thenReturn(branchIds);
View Full Code Here

Examples of org.jtalks.common.model.entity.Section.addOrUpdateBranch()

        Branch branch1 = new Branch("my branch", "1");
        branch1.setId(42);
        Branch branch2 = new Branch("my branch2", "2");
        branch2.setId(43);
        section.addOrUpdateBranch(branch1);
        section.addOrUpdateBranch(branch2);
        when(userService.getCurrentUser()).thenReturn(user);
        List<Long> branchIds = Arrays.asList(branch1.getId());
        when(sectionDao.getAvailableBranchIds(user, section.getBranches())).thenReturn(branchIds);

        List<Post> posts = new ArrayList<>();
View Full Code Here

Examples of org.jtalks.common.model.entity.Section.addOrUpdateBranch()

    @Test
    public void testBranchesCascadingDeletesFromSection() {
        Branch actualBranch = ObjectsFactory.getDefaultBranch();
        Section section = ObjectsFactory.getDefaultSection();
        section.addOrUpdateBranch(actualBranch);
        branchDao.saveOrUpdate(actualBranch);
        dao.saveOrUpdate(section);
        session.flush();
        Branch expectedBranch = branchDao.get(actualBranch.getId());
        assertEquals(expectedBranch.getName(), actualBranch.getName());
View Full Code Here

Examples of org.jtalks.common.model.entity.Section.addOrUpdateBranch()

    public void testGetAllTopicInBranchCount() {
        Section section = ObjectsFactory.getDefaultSection();
        Branch branch = ObjectsFactory.getDefaultBranch();
        Topic topic = ObjectsFactory.getDefaultTopic();
        branch.addTopic(topic);
        section.addOrUpdateBranch(branch);
        session.save(section);

        List<Section> sectionList = dao.getAll();

        assertEquals(((Branch) sectionList.get(0).getBranches().get(0)).getTopicCount(), 1);
View Full Code Here

Examples of org.jtalks.common.model.entity.Section.addOrUpdateBranch()

    @Test
    public void testTopicInBranch() {
        Section section = ObjectsFactory.getDefaultSection();
        Branch branch = ObjectsFactory.getDefaultBranch();
        Topic topic = ObjectsFactory.getDefaultTopic();
        section.addOrUpdateBranch(branch);
        session.save(section);

        Section sectionTwo = dao.get(1L);
        Branch branchTwo = (Branch) section.getBranches().get(0);
View Full Code Here

Examples of org.jtalks.common.model.entity.Section.addOrUpdateBranch()

        List<Branch> branches = new ArrayList<>();
        Section section = ObjectsFactory.getDefaultSection();
        section.setPosition(sectionPosition);
        for (int i = 0; i < size; i++) {
            Branch newBranch = new Branch("Branch #" + i, "Branch #" + i);
            section.addOrUpdateBranch(newBranch);
            newBranch.setSection(section);
            branches.add(newBranch);
        }
        session.save(section);
        return branches;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.