Merged mward/5.2.n-repo-1583-groupmem (5.2.1) to 5.2.N (5.2.1)

134294 mward: REPO-1583: add test and implementation details


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@134399 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2017-01-17 14:13:49 +00:00
parent 9b4f773498
commit 4acd852e05
5 changed files with 108 additions and 11 deletions

View File

@@ -25,12 +25,7 @@
*/
package org.alfresco.rest.api.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.text.ParseException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -45,6 +40,7 @@ import org.alfresco.rest.api.tests.client.PublicApiClient;
import org.alfresco.rest.api.tests.client.PublicApiClient.Groups;
import org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse;
import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
import org.alfresco.rest.api.tests.client.PublicApiException;
import org.alfresco.rest.api.tests.client.data.Group;
import org.alfresco.rest.api.tests.client.data.GroupMember;
import org.alfresco.rest.framework.resource.parameters.SortColumn;
@@ -55,6 +51,8 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* V1 REST API tests for managing Groups
*
@@ -420,6 +418,12 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
return groupsProxy.getGroupMembers(groupId, createParams(paging, otherParams), errorMessage, expectedStatus);
}
private ListResponse<Group> getGroupsByPersonId(String userId, final PublicApiClient.Paging paging, Map<String, String> otherParams, String errorMessage, int expectedStatus) throws Exception
{
final Groups groupsProxy = publicApiClient.groups();
return groupsProxy.getGroupsByPersonId(userId, createParams(paging, otherParams), errorMessage, expectedStatus);
}
private ListResponse<GroupMember> getGroupMembers(String groupId, final PublicApiClient.Paging paging, Map<String, String> otherParams) throws Exception
{
return getGroupMembers(groupId, paging, otherParams, "Failed to get group members", HttpServletResponse.SC_OK);
@@ -445,6 +449,29 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
}
}
@Test
public void testGetGroupsByUserId() throws Exception
{
try
{
createAuthorityContext(user1);
setRequestContext(networkAdmin);
canGetGroupsForUserId();
// TODO: get details for -me- without 403
}
finally
{
clearAuthorityContext();
}
}
private void canGetGroupsForUserId() throws ParseException, PublicApiException
{
Groups groupsProxy = publicApiClient.groups();
ListResponse<Group> groups = groupsProxy.getGroupsByPersonId(user1, null, "Couldn't get user's groups", 200);
assertEquals(5L, (long) groups.getPaging().getCount());
}
private void testGetGroupMembersByGroupId() throws Exception
{
Paging paging = getPaging(0, 4);