Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.Branch


    }
   
    @Test
    public void markAllTopicsAsReadShouldMarkThemAndUpdatePage() throws NotFoundException {
        Long markedBranchId = 1L;
        Branch willBeMarkedBranch = new Branch("branch", "new branch");
        when(branchService.get(markedBranchId)).thenReturn(willBeMarkedBranch);
       
        String result = controller.markAllTopicsAsRead(markedBranchId);
       
        assertEquals(result, "redirect:/branches/" + String.valueOf(markedBranchId));
View Full Code Here


            throws Exception {
        long branchId = 42;
        Component component = setupComponentMock();

        GroupsPermissions expectedPermissions = new GroupsPermissions();
        Branch expectedBranch = new Branch("name", "description");
        when(branchService.get(branchId)).thenReturn(expectedBranch);
        doReturn(expectedPermissions).when(branchService).getPermissionsFor(component.getId(), branchId);

        mockMvc = MockMvcBuilders.standaloneSetup(administrationController).build();
        this.mockMvc.perform(get("/branch/permissions/42").accept(MediaType.TEXT_HTML))
View Full Code Here

    @BeforeMethod
    public void init() throws NotFoundException {
        initMocks(this);

        Branch branch = new Branch("branch", "branch");
        branch.setId(BRANCH_ID);

        Topic topic = new Topic(user, "title");
        topic.setBranch(branch);
        topic.setId(TOPIC_ID);
View Full Code Here

    public ModelAndView showPage(@PathVariable("branchId") long branchId,
                                 @RequestParam(value = PAGE, defaultValue = "1", required = false) String page
    ) throws NotFoundException {

        branchService.checkIfBranchExists(branchId);
        Branch branch = branchService.get(branchId);
        Page<Topic> topicsPage = topicFetchService.getTopics(branch, page);
        lastReadPostService.fillLastReadPostForTopics(topicsPage.getContent());

        JCUser currentUser = userService.getCurrentUser();
        List<Breadcrumb> breadcrumbs = breadcrumbBuilder.getForumBreadcrumb(branch);

        return new ModelAndView("topic/topicList")
                .addObject("viewList", locationService.getUsersViewing(branch))
                .addObject("branch", branch)
                .addObject("topicsPage", topicsPage)
                .addObject("breadcrumbList", breadcrumbs)
                .addObject("topicTypes", getTopicTypes(branchId))
                .addObject("subscribed", branch.getSubscribers().contains(currentUser));
    }
View Full Code Here

     * @return {@code ModelAndView} with post list and vars for pagination
     */
    @RequestMapping("/branches/{branchId}/recent")
    public ModelAndView recentBranchPostsPage(@PathVariable("branchId") long branchId) throws NotFoundException {
        branchService.checkIfBranchExists(branchId);
        Branch branch = branchService.get(branchId);

        List<Post> posts = postService.getLastPostsFor(branch, RECENT_POST_COUNT);

        return new ModelAndView("posts/recent")
                .addObject("feedTitle", branch.getName())
                .addObject("feedDescription", branch.getDescription())
                .addObject("urlSuffix", branch.prepareUrlSuffix())
                .addObject("posts", posts);

    }
View Full Code Here

     */
    @RequestMapping(value = "/branch/permissions/{branchId}", method = RequestMethod.GET)
    public ModelAndView showBranchPermissions(@PathVariable("branchId") long branchId) throws NotFoundException {
        long forumId = componentService.getComponentOfForum().getId();
        GroupsPermissions permissions = branchService.getPermissionsFor(forumId, branchId);
        Branch branch = branchService.get(branchId);
        return new ModelAndView("branchPermissions")
                .addObject("branch", branch)
                .addObject("permissions", permissions);
    }
View Full Code Here

        manager = new PermissionManager(aclManager, groupDao, aclUtil, pluginPermissionManager);
    }

    @Test(dataProvider = "accessChanges")
    public void testChangeGrants(PermissionChanges changes) throws Exception {
        Branch branch = ObjectsFactory.getDefaultBranch();

        manager.changeGrants(branch, changes);

        verify(aclManager, times(changes.getRemovedGroups().size())).
                delete(anyListOf(Sid.class), eq(listFromArray(changes.getPermission())), eq(branch));
View Full Code Here

                grant(anyListOf(Sid.class), eq(listFromArray(changes.getPermission())), eq(branch));
    }

    @Test(dataProvider = "accessChanges")
    public void testChangeRestriction(PermissionChanges changes) throws Exception {
        Branch branch = ObjectsFactory.getDefaultBranch();

        manager.changeRestrictions(branch, changes);

        verify(aclManager, times(changes.getRemovedGroups().size())).
                delete(anyListOf(Sid.class), eq(listFromArray(changes.getPermission())), eq(branch));
View Full Code Here

                restrict(anyListOf(Sid.class), eq(listFromArray(changes.getPermission())), eq(branch));
    }

    @Test
    public void testGetPermissionsMapForBranch() throws Exception {
        Branch branch = PersistedObjectsFactory.getDefaultBranch();
        givenPermissions(branch, BranchPermission.values());

        GroupsPermissions groupsPermissions = manager.getPermissionsMapFor(branch);
        verify(pluginPermissionManager).getPluginsBranchPermissions();
        verify(aclManager).getGroupPermissionsOn(branch);
View Full Code Here

        }
    }

    @Test
    public void testChangeGrantsOfAnonymousGroup() throws Exception {
        Branch branch = ObjectsFactory.getDefaultBranch();
        PermissionChanges changes = new PermissionChanges(BranchPermission.CLOSE_TOPICS);
        List<Group> groupList = new ArrayList<>();
        groupList.add(AnonymousGroup.ANONYMOUS_GROUP);
        changes.addNewlyAddedGroups(groupList);
        manager.changeGrants(branch, changes);
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.Branch

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.