Search in sources :

Example 1 with GroupMember

use of org.alfresco.rest.api.tests.client.data.GroupMember in project alfresco-remote-api by Alfresco.

the class GroupsTest method createAuthorityContext.

/**
 * Creates authority context.
 *
 * @param userName
 *            The user to run as.
 */
private void createAuthorityContext(String userName) throws PublicApiException {
    String groupName = "Group_ROOT" + GUID.generate();
    AuthenticationUtil.setRunAsUser(userName);
    if (rootGroupName == null) {
        rootGroupName = authorityService.getName(AuthorityType.GROUP, groupName);
    }
    if (!authorityService.authorityExists(rootGroupName)) {
        AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
        rootGroupName = authorityService.createAuthority(AuthorityType.GROUP, groupName);
        authorityService.addAuthorityToZones(rootGroupName, zoneSet("APITEST.MYZONE"));
        authorityService.setAuthorityDisplayName(rootGroupName, "Root Group");
        String groupBAuthorityName = authorityService.createAuthority(AuthorityType.GROUP, "Test_GroupB" + GUID.generate());
        authorityService.setAuthorityDisplayName(groupBAuthorityName, "B Group");
        authorityService.addAuthority(rootGroupName, groupBAuthorityName);
        authorityService.addAuthorityToZones(groupBAuthorityName, zoneSet("APITEST.MYZONE"));
        when(groupBResultSetRow.getNodeRef()).thenReturn(authorityService.getAuthorityNodeRef(groupBAuthorityName));
        String groupAAuthorityName = authorityService.createAuthority(AuthorityType.GROUP, "Test_GroupA" + GUID.generate());
        authorityService.setAuthorityDisplayName(groupAAuthorityName, "A Group");
        authorityService.addAuthority(rootGroupName, groupAAuthorityName);
        authorityService.addAuthorityToZones(groupAAuthorityName, zoneSet("APITEST.MYZONE", "APITEST.ANOTHER"));
        when(groupAResultSetRow.getNodeRef()).thenReturn(authorityService.getAuthorityNodeRef(groupAAuthorityName));
        authorityService.addAuthority(groupAAuthorityName, user1);
        authorityService.addAuthority(groupBAuthorityName, user2);
        rootGroup = new Group();
        rootGroup.setId(rootGroupName);
        rootGroup.setDisplayName("Root Group");
        groupA = new Group();
        groupA.setId(groupAAuthorityName);
        groupA.setDisplayName("A Group");
        groupB = new Group();
        groupB.setId(groupBAuthorityName);
        groupB.setDisplayName("B Group");
        groupMemberA = new GroupMember();
        groupMemberA.setId(groupAAuthorityName);
        groupMemberA.setMemberType(AuthorityType.GROUP.toString());
        groupMemberB = new GroupMember();
        groupMemberB.setId(groupBAuthorityName);
        groupMemberB.setMemberType(AuthorityType.GROUP.toString());
    }
    {
        publicApiClient.setRequestContext(new RequestContext(networkOne.getId(), networkAdmin, "admin"));
        Person personAlice = new Person();
        String aliceId = "alice-" + UUID.randomUUID() + "@" + networkOne.getId();
        personAlice.setUserName(aliceId);
        personAlice.setId(aliceId);
        personAlice.setFirstName("Alice");
        personAlice.setEmail("alison.smith@example.com");
        personAlice.setPassword("password");
        personAlice.setEnabled(true);
        PublicApiClient.People people = publicApiClient.people();
        people.create(personAlice);
        personMember = new GroupMember();
        personMember.setId(personAlice.getId());
        personMember.setMemberType(MEMBER_TYPE_PERSON);
    }
}
Also used : Group(org.alfresco.rest.api.tests.client.data.Group) GroupMember(org.alfresco.rest.api.tests.client.data.GroupMember) RequestContext(org.alfresco.rest.api.tests.client.RequestContext) Person(org.alfresco.rest.api.tests.client.data.Person)

Example 2 with GroupMember

use of org.alfresco.rest.api.tests.client.data.GroupMember in project alfresco-remote-api by Alfresco.

the class GroupsTest method testGetGroupsByMemberType.

private void testGetGroupsByMemberType(String groupId, String memberType) throws Exception {
    // Sort params
    Map<String, String> otherParams = new HashMap<>();
    otherParams.put("where", "(memberType=" + memberType + ")");
    // Paging
    Paging paging = getPaging(0, 4);
    ListResponse<GroupMember> resp = getGroupMembers(groupId, paging, otherParams);
    resp.getList().forEach(groupMember -> {
        validateGroupMemberDefaultFields(groupMember);
        assertEquals("memberType was expected to be " + memberType, memberType, groupMember.getMemberType());
    });
}
Also used : GroupMember(org.alfresco.rest.api.tests.client.data.GroupMember) Paging(org.alfresco.rest.api.tests.client.PublicApiClient.Paging)

Aggregations

GroupMember (org.alfresco.rest.api.tests.client.data.GroupMember)2 Paging (org.alfresco.rest.api.tests.client.PublicApiClient.Paging)1 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)1 Group (org.alfresco.rest.api.tests.client.data.Group)1 Person (org.alfresco.rest.api.tests.client.data.Person)1