Package org.nuxeo.ecm.social.workspace.computedgroups

Examples of org.nuxeo.ecm.social.workspace.computedgroups.SocialWorkspaceGroupComputer


        assert userManager instanceof UserManagerWithComputedGroups;
    }

    @Test
    public void testSocialWorkspaceComputer() throws Exception {
        SocialWorkspaceGroupComputer computer = new SocialWorkspaceGroupComputer();

        SocialWorkspace sw = createSocialWorkspace("mySocialWorkspace", true);
        assertNotNull(sw);
        SocialWorkspace sw2 = createSocialWorkspace("mySocialWorkspace2", true);
        assertNotNull(sw);

        // Rights for SocialWorkspace: 1 admin and 2 members
        assertTrue(addBidirectionalRelation(
                ActivityHelper.createUserActivityObject("userComputer"),
                ActivityHelper.createDocumentActivityObject(sw.getDocument()),
                buildRelationAdministratorKind()));
        assertTrue(addBidirectionalRelation(
                ActivityHelper.createUserActivityObject("userComputer2"),
                ActivityHelper.createDocumentActivityObject(sw.getDocument()),
                buildRelationMemberKind()));
        assertTrue(addBidirectionalRelation(
                ActivityHelper.createUserActivityObject("userComputer3"),
                ActivityHelper.createDocumentActivityObject(sw.getDocument()),
                buildRelationMemberKind()));

        assertEquals(
                3,
                computer.getGroupMembers(
                        getSocialWorkspaceMembersGroupName(sw.getDocument())).size());

        // There is the creator and a freshly added one.
        assertEquals(
                2,
                computer.getGroupMembers(
                        getSocialWorkspaceAdministratorsGroupName(sw.getDocument())).size());

        // Right for SocialWorkspace 2: 1 admin and 0 member
        assertTrue(addBidirectionalRelation(
                ActivityHelper.createUserActivityObject("userComputer2"),
                ActivityHelper.createDocumentActivityObject(sw2.getDocument()),
                buildRelationAdministratorKind()));

        assertEquals(
                2,
                computer.getGroupMembers(
                        getSocialWorkspaceAdministratorsGroupName(sw2.getDocument())).size());
        assertEquals(
                1,
                computer.getGroupMembers(
                        getSocialWorkspaceMembersGroupName(sw2.getDocument())).size());

        DocumentModel user1 = userManager.getBareUserModel();
        user1.setProperty(userManager.getUserSchemaName(),
                userManager.getUserIdField(), "userComputer2");
        userManager.createUser(user1);
        session.save();

        NuxeoPrincipal principal = userManager.getPrincipal("userComputer2");

        List<String> groups = computer.getGroupsForUser((NuxeoPrincipalImpl) principal);

        assertEquals(2, groups.size());
        assertTrue(groups.contains(getSocialWorkspaceAdministratorsGroupName(sw2.getDocument())));
        assertTrue(groups.contains(getSocialWorkspaceMembersGroupName(sw.getDocument())));
View Full Code Here

TOP

Related Classes of org.nuxeo.ecm.social.workspace.computedgroups.SocialWorkspaceGroupComputer

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.