Package org.jtalks.jcommune.model.entity

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


    @Test
    public void showPage() throws NotFoundException {
        long branchId = 1L;
        String page = "2";
        Branch branch = new Branch("name", "description");
        branch.setId(branchId);
        Pageable pageRequest = new PageRequest(2, 5);
        Page<Topic> topicsPage = new PageImpl<>(Collections.<Topic> emptyList(), pageRequest, 0);
        //set expectations
        when(branchService.get(branchId)).thenReturn(branch);
        when(topicFetchService.getTopics(branch, page)).thenReturn(topicsPage);
        when(breadcrumbBuilder.getForumBreadcrumb(branchService.get(branchId)))
                .thenReturn(new ArrayList<Breadcrumb>());
        when(forumStatisticsProvider.getOnlineRegisteredUsers()).thenReturn(new ArrayList<>());

        SecurityContext securityContext = mock(SecurityContext.class);
        when(securityContextFacade.getContext()).thenReturn(securityContext);
        Authentication authentication = mock(Authentication.class);
        when(securityContext.getAuthentication()).thenReturn(authentication);
        //invoke the object under test
        ModelAndView mav = controller.showPage(branchId, page);

        //check expectations
        verify(breadcrumbBuilder).getForumBreadcrumb(branchService.get(branchId));

        //check result
        assertViewName(mav, "topic/topicList");

        Branch actualBranch = assertAndReturnModelAttributeOfType(mav, "branch", Branch.class);
        assertEquals(actualBranch.getId(), branchId);

        @SuppressWarnings("unchecked")
        Page<Topic> actualTopicsPage =
            (Page<Topic>) assertAndReturnModelAttributeOfType(mav, "topicsPage", Page.class);
        assertEquals(actualTopicsPage, topicsPage);
View Full Code Here


    public void testViewList() throws NotFoundException {
        long branchId = 1L;
        String page = "2";
        Pageable pageRequest = new PageRequest(2, 5);
        Page<Topic> topicsPage = new PageImpl<>(Collections.<Topic> emptyList(), pageRequest, 0);
        Branch branch = new Branch("name", "description");
        branch.setId(branchId);
        //set expectations
        when(branchService.get(branchId)).thenReturn(branch);
        when(breadcrumbBuilder.getForumBreadcrumb(branchService.get(branchId)))
                .thenReturn(new ArrayList<Breadcrumb>());
        when(forumStatisticsProvider.getOnlineRegisteredUsers()).thenReturn(new ArrayList<>());
View Full Code Here

    @Test
    public void testGetBranchesFromSection() throws NotFoundException {
        long sectionId = 1L;
        List<Branch> branches = new ArrayList<>();
        Branch branch = createDefaultBranch();
        branches.add(branch);
        when(branchService.getAvailableBranchesInSection(sectionId,
                branch.getTopics().get(0).getId())).thenReturn(branches);

        BranchDto[] branchDtoArray = controller.getBranchesFromSection(sectionId, branch.getTopics().get(0).getId());

        assertEquals(branchDtoArray.length, branches.size());
        assertEquals(branchDtoArray[0].getId(), branch.getId());
        assertEquals(branchDtoArray[0].getName(), branch.getName());
    }
View Full Code Here

    }

    @Test
    public void testGetAllBranches() throws NotFoundException {
        List<Branch> branches = new ArrayList<>();
        Branch branch = createDefaultBranch();
        branches.add(branch);
        when(branchService.getAllAvailableBranches(branch.getTopics().get(0).getId())).thenReturn(branches);

        BranchDto[] branchDtoArray = controller.getAllBranches(branch.getTopics().get(0).getId());

        assertEquals(branchDtoArray.length, branches.size());
        assertEquals(branchDtoArray[0].getId(), branch.getId());
        assertEquals(branchDtoArray[0].getName(), branch.getName());
    }
View Full Code Here

        long branchId = 1L;
        long topicId = 1L;
        JCUser user = new JCUser("username", "email", "password");
        Topic topic = new Topic(user, "Topic title");
        topic.setId(topicId);
        Branch branch = new Branch("name", "description");
        branch.setId(branchId);
        branch.addTopic(topic);
        return branch;
    }
View Full Code Here

                codeReviewCommentService);
    }

    @BeforeMethod
    public void prepareTestData() {
        branch = new Branch("", "description");
        branch.setId(BRANCH_ID);
    }
View Full Code Here

     * @return redirect to the same branch page
     * @throws NotFoundException if no branch matches id given
     */
    @RequestMapping("/branches/{id}/markread")
    public String markAllTopicsAsRead(@PathVariable long id) throws NotFoundException {
        Branch branch = branchService.get(id);
        lastReadPostService.markAllTopicsAsRead(branch);
        return "redirect:/branches/" + id;
    }
View Full Code Here

        permissionService.hasBranchPermission(1L, BranchPermission.EDIT_OWN_POSTS);
    }

    @Test
    public void testGetPermissionsFor() {
        Branch branch = mock(Branch.class);
        doReturn(new GroupsPermissions()).when(permissionManager).getPermissionsMapFor(branch);
        assertNotNull(permissionService.getPermissionsFor(branch));
    }
View Full Code Here

    }

    @Test
    public void testChangeGrants() {
        PermissionChanges changes = mock(PermissionChanges.class);
        Branch branch = mock(Branch.class);
        permissionService.changeGrants(branch, changes);

        Component component = mock(Component.class);
        permissionService.changeGrants(component, changes);
View Full Code Here

    }

    @Test
    public void testChangeRestrictions() {
        PermissionChanges changes = mock(PermissionChanges.class);
        Branch branch = mock(Branch.class);
        permissionService.changeRestrictions(branch, changes);

        Component component = mock(Component.class);
        permissionService.changeRestrictions(component, 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.