mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
132482 rmunteanu: REPO-556, REPO-1534: List People - OrderBy not working with "id" - fixed orderBy issue, now people list can be ordered by "id" key - added more tests for list people endpoint git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132671 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -37,7 +37,7 @@ public interface People
|
|||||||
|
|
||||||
String PARAM_FIRST_NAME = "firstName";
|
String PARAM_FIRST_NAME = "firstName";
|
||||||
String PARAM_LAST_NAME = "lastName";
|
String PARAM_LAST_NAME = "lastName";
|
||||||
String PARAM_USER_NAME = "userName";
|
String PARAM_ID = "id";
|
||||||
|
|
||||||
String validatePerson(String personId);
|
String validatePerson(String personId);
|
||||||
String validatePerson(String personId, boolean validateIsCurrentUser);
|
String validatePerson(String personId, boolean validateIsCurrentUser);
|
||||||
|
@@ -94,7 +94,7 @@ public class PeopleImpl implements People
|
|||||||
Map<String, QName> aMap = new HashMap<>(3);
|
Map<String, QName> aMap = new HashMap<>(3);
|
||||||
aMap.put(PARAM_FIRST_NAME, ContentModel.PROP_FIRSTNAME);
|
aMap.put(PARAM_FIRST_NAME, ContentModel.PROP_FIRSTNAME);
|
||||||
aMap.put(PARAM_LAST_NAME, ContentModel.PROP_LASTNAME);
|
aMap.put(PARAM_LAST_NAME, ContentModel.PROP_LASTNAME);
|
||||||
aMap.put(PARAM_USER_NAME, ContentModel.PROP_USERNAME);
|
aMap.put(PARAM_ID, ContentModel.PROP_USERNAME);
|
||||||
sort_params_to_qnames = Collections.unmodifiableMap(aMap);
|
sort_params_to_qnames = Collections.unmodifiableMap(aMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,6 +70,7 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
private String account3Admin;
|
private String account3Admin;
|
||||||
private String account4Admin;
|
private String account4Admin;
|
||||||
private Person personAlice;
|
private Person personAlice;
|
||||||
|
private Person personAliceD;
|
||||||
private Person personBen;
|
private Person personBen;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -715,10 +716,8 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PublicApiClient.ListResponse<Person> listPeople(final PublicApiClient.Paging paging, String sortColumn, boolean asc) throws Exception
|
private PublicApiClient.ListResponse<Person> listPeople(final PublicApiClient.Paging paging, String sortColumn, boolean asc, int statusCode) throws Exception
|
||||||
{
|
{
|
||||||
final PublicApiClient.People peopleProxy = publicApiClient.people();
|
|
||||||
|
|
||||||
// sort params
|
// sort params
|
||||||
final Map<String, String> params = new HashMap<>();
|
final Map<String, String> params = new HashMap<>();
|
||||||
if (sortColumn != null)
|
if (sortColumn != null)
|
||||||
@@ -726,12 +725,19 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
params.put("orderBy", sortColumn + " " + (asc ? "ASC" : "DESC"));
|
params.put("orderBy", sortColumn + " " + (asc ? "ASC" : "DESC"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return peopleProxy.getPeople(createParams(paging, params));
|
HttpResponse response = people.getAll("people", null, null, null, createParams(paging, params), "Failed to get people", statusCode);
|
||||||
|
JSONObject jsonList = (JSONObject) response.getJsonResponse().get("list");
|
||||||
|
if (jsonList == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Person.parsePeople(response.getJsonResponse());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the capability to sort and paginate the list of people orderBy =
|
* Tests the capability to sort and paginate the list of people orderBy =
|
||||||
* firstName ASC skip = 1, count = 2
|
* firstName ASC skip = 1, count = 3
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@@ -742,15 +748,16 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
|
|
||||||
// paging
|
// paging
|
||||||
int skipCount = 1;
|
int skipCount = 1;
|
||||||
int maxItems = 2;
|
int maxItems = 3;
|
||||||
int totalResults = 4;
|
int totalResults = 5;
|
||||||
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
||||||
|
|
||||||
// orderBy=firstName ASC
|
// orderBy=firstName ASC
|
||||||
PublicApiClient.ListResponse<Person> resp = listPeople(paging, "firstName", true);
|
PublicApiClient.ListResponse<Person> resp = listPeople(paging, "firstName", true, 200);
|
||||||
|
|
||||||
List<Person> expectedList = new LinkedList<>();
|
List<Person> expectedList = new LinkedList<>();
|
||||||
expectedList.add(personAlice);
|
expectedList.add(personAlice);
|
||||||
|
expectedList.add(personAliceD);
|
||||||
expectedList.add(personBen);
|
expectedList.add(personBen);
|
||||||
|
|
||||||
checkList(expectedList, paging.getExpectedPaging(), resp);
|
checkList(expectedList, paging.getExpectedPaging(), resp);
|
||||||
@@ -758,7 +765,7 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the capability to sort and paginate the list of people orderBy =
|
* Tests the capability to sort and paginate the list of people orderBy =
|
||||||
* firstName DESC skip = 1, count = 2
|
* firstName DESC skip = 1, count = 3
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@@ -769,23 +776,24 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
|
|
||||||
// paging
|
// paging
|
||||||
int skipCount = 1;
|
int skipCount = 1;
|
||||||
int maxItems = 2;
|
int maxItems = 3;
|
||||||
int totalResults = 4;
|
int totalResults = 5;
|
||||||
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
||||||
|
|
||||||
// orderBy=firstName DESC
|
// orderBy=firstName DESC
|
||||||
PublicApiClient.ListResponse<Person> resp = listPeople(paging, "firstName", false);
|
PublicApiClient.ListResponse<Person> resp = listPeople(paging, "firstName", false, 200);
|
||||||
|
|
||||||
List<Person> expectedList = new LinkedList<>();
|
List<Person> expectedList = new LinkedList<>();
|
||||||
expectedList.add((Person) personBen);
|
expectedList.add((Person) personBen);
|
||||||
expectedList.add((Person) personAlice);
|
expectedList.add((Person) personAlice);
|
||||||
|
expectedList.add((Person) personAliceD);
|
||||||
|
|
||||||
checkList(expectedList, paging.getExpectedPaging(), resp);
|
checkList(expectedList, paging.getExpectedPaging(), resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the capability to sort and paginate the list of people verifies
|
* Tests the capability paginate the list of people verifies default
|
||||||
* default sorting, skip = 1, count = 2
|
* sorting, skip = 1, count = 3
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@@ -796,15 +804,120 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
|
|
||||||
// paging
|
// paging
|
||||||
int skipCount = 1;
|
int skipCount = 1;
|
||||||
int maxItems = 2;
|
int maxItems = 3;
|
||||||
int totalResults = 4;
|
int totalResults = 5;
|
||||||
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
||||||
|
|
||||||
// orderBy=firstName DESC
|
PublicApiClient.ListResponse<Person> resp = listPeople(paging, null, false, 200);
|
||||||
PublicApiClient.ListResponse<Person> resp = listPeople(paging, null, false);
|
|
||||||
|
|
||||||
List<Person> expectedList = new LinkedList<>();
|
List<Person> expectedList = new LinkedList<>();
|
||||||
expectedList.add((Person) personAlice);
|
expectedList.add((Person) personAlice);
|
||||||
|
expectedList.add((Person) personAliceD);
|
||||||
|
expectedList.add((Person) personBen);
|
||||||
|
|
||||||
|
checkList(expectedList, paging.getExpectedPaging(), resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the capability to sort and paginate the list of people orderBy =
|
||||||
|
* username DESC skip = 1, count = 3
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPagingAndSortingByIdDesc() throws Exception
|
||||||
|
{
|
||||||
|
initializeContextForGetPeople();
|
||||||
|
|
||||||
|
// paging
|
||||||
|
int skipCount = 1;
|
||||||
|
int maxItems = 3;
|
||||||
|
int totalResults = 5;
|
||||||
|
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
||||||
|
|
||||||
|
// orderBy=userName DESC
|
||||||
|
PublicApiClient.ListResponse<Person> resp = listPeople(paging, "id", false, 200);
|
||||||
|
|
||||||
|
List<Person> expectedList = new LinkedList<>();
|
||||||
|
expectedList.add((Person) personBen);
|
||||||
|
expectedList.add((Person) personAliceD);
|
||||||
|
expectedList.add((Person) personAlice);
|
||||||
|
|
||||||
|
checkList(expectedList, paging.getExpectedPaging(), resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the capability to sort and paginate the list of people orderBy =
|
||||||
|
* invalid sort key ASC skip = 1, count = 3
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPagingAndSortingByInvalidSortKey() throws Exception
|
||||||
|
{
|
||||||
|
initializeContextForGetPeople();
|
||||||
|
|
||||||
|
// paging
|
||||||
|
int skipCount = 1;
|
||||||
|
int maxItems = 3;
|
||||||
|
int totalResults = 5;
|
||||||
|
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
||||||
|
|
||||||
|
// orderBy=invalidSortKey ASC
|
||||||
|
listPeople(paging, "invalidSortKey", true, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the capability to sort and paginate the list of people orderBy =
|
||||||
|
* lastName ASC skip = 2, count = 3
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPagingAndSortingByLastName() throws Exception
|
||||||
|
{
|
||||||
|
initializeContextForGetPeople();
|
||||||
|
|
||||||
|
// paging
|
||||||
|
int skipCount = 2;
|
||||||
|
int maxItems = 3;
|
||||||
|
int totalResults = 5;
|
||||||
|
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
||||||
|
|
||||||
|
// orderBy=lastName ASC
|
||||||
|
PublicApiClient.ListResponse<Person> resp = listPeople(paging, "lastName", true, 200);
|
||||||
|
|
||||||
|
List<Person> expectedList = new LinkedList<>();
|
||||||
|
expectedList.add((Person) personBen);
|
||||||
|
expectedList.add((Person) personAliceD);
|
||||||
|
expectedList.add((Person) personAlice);
|
||||||
|
|
||||||
|
checkList(expectedList, paging.getExpectedPaging(), resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the capability to sort and paginate the list of people orderBy =
|
||||||
|
* both firstName and lastName ASC skip = 1, count = 3
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPagingAndSortingByFirstNameAndLastName() throws Exception
|
||||||
|
{
|
||||||
|
initializeContextForGetPeople();
|
||||||
|
|
||||||
|
// paging
|
||||||
|
int skipCount = 1;
|
||||||
|
int maxItems = 3;
|
||||||
|
int totalResults = 5;
|
||||||
|
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
||||||
|
|
||||||
|
// orderBy=firstName,lastName ASC
|
||||||
|
PublicApiClient.ListResponse<Person> resp = listPeople(paging, "firstName,lastName", true, 200);
|
||||||
|
|
||||||
|
List<Person> expectedList = new LinkedList<>();
|
||||||
|
expectedList.add((Person) personAliceD);
|
||||||
|
expectedList.add((Person) personAlice);
|
||||||
expectedList.add((Person) personBen);
|
expectedList.add((Person) personBen);
|
||||||
|
|
||||||
checkList(expectedList, paging.getExpectedPaging(), resp);
|
checkList(expectedList, paging.getExpectedPaging(), resp);
|
||||||
@@ -823,11 +936,22 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
personAlice.setEnabled(true);
|
personAlice.setEnabled(true);
|
||||||
people.create(personAlice);
|
people.create(personAlice);
|
||||||
|
|
||||||
|
publicApiClient.setRequestContext(new RequestContext(account4.getId(), account4Admin, "admin"));
|
||||||
|
personAliceD = new Person();
|
||||||
|
personAliceD.setUserName("aliced@" + account4.getId());
|
||||||
|
personAliceD.setId("aliced@" + account4.getId());
|
||||||
|
personAliceD.setFirstName("Alice");
|
||||||
|
personAliceD.setLastName("Davis");
|
||||||
|
personAliceD.setEmail("alison.davis@example.com");
|
||||||
|
personAliceD.setPassword("password");
|
||||||
|
personAliceD.setEnabled(true);
|
||||||
|
people.create(personAliceD);
|
||||||
|
|
||||||
personBen = new Person();
|
personBen = new Person();
|
||||||
personBen.setUserName("ben@" + account4.getId());
|
personBen.setUserName("ben@" + account4.getId());
|
||||||
personBen.setId("ben@" + account4.getId());
|
personBen.setId("ben@" + account4.getId());
|
||||||
personBen.setFirstName("Ben");
|
personBen.setFirstName("Ben");
|
||||||
personBen.setLastName("Smythe");
|
personBen.setLastName("Carson");
|
||||||
personBen.setEmail("ben.smythe@example.com");
|
personBen.setEmail("ben.smythe@example.com");
|
||||||
personBen.setPassword("password");
|
personBen.setPassword("password");
|
||||||
personBen.setEnabled(true);
|
personBen.setEnabled(true);
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.tests.client;
|
package org.alfresco.rest.api.tests.client;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -49,7 +48,26 @@ import org.alfresco.rest.api.tests.TestPeople;
|
|||||||
import org.alfresco.rest.api.tests.TestSites;
|
import org.alfresco.rest.api.tests.TestSites;
|
||||||
import org.alfresco.rest.api.tests.client.PublicApiHttpClient.BinaryPayload;
|
import org.alfresco.rest.api.tests.client.PublicApiHttpClient.BinaryPayload;
|
||||||
import org.alfresco.rest.api.tests.client.PublicApiHttpClient.RequestBuilder;
|
import org.alfresco.rest.api.tests.client.PublicApiHttpClient.RequestBuilder;
|
||||||
import org.alfresco.rest.api.tests.client.data.*;
|
import org.alfresco.rest.api.tests.client.data.Activities;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.Activity;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.CMISNode;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.Comment;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.ContentData;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.Favourite;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.FavouriteSite;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.FolderNode;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.JSONAble;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.MemberOfSite;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.NodeRating;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.Person;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.PersonNetwork;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.Preference;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.Site;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.SiteContainer;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.SiteImpl;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.SiteMember;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.SiteMembershipRequest;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.Tag;
|
||||||
import org.apache.chemistry.opencmis.client.api.CmisObject;
|
import org.apache.chemistry.opencmis.client.api.CmisObject;
|
||||||
import org.apache.chemistry.opencmis.client.api.Document;
|
import org.apache.chemistry.opencmis.client.api.Document;
|
||||||
import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
|
import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
|
||||||
@@ -640,28 +658,26 @@ public class PublicApiClient
|
|||||||
|
|
||||||
public class AbstractProxy
|
public class AbstractProxy
|
||||||
{
|
{
|
||||||
public HttpResponse getAll(String entityCollectionName, String entityId, String relationCollectionName, String relationId, Map<String, String> params, String errorMessage) throws PublicApiException
|
public HttpResponse getAll(String entityCollectionName, String entityId, String relationCollectionName, String relationId, Map<String, String> params, String errorMessage)
|
||||||
{
|
throws PublicApiException
|
||||||
try
|
{
|
||||||
{
|
return getAll(entityCollectionName, entityId, relationCollectionName, relationId, params, errorMessage, HttpServletResponse.SC_OK);
|
||||||
HttpResponse response = get("public", entityCollectionName, entityId, relationCollectionName, relationId, params);
|
}
|
||||||
|
|
||||||
if (HttpServletResponse.SC_OK != response.getStatusCode())
|
public HttpResponse getAll(String entityCollectionName, String entityId, String relationCollectionName, String relationId, Map<String, String> params, String errorMessage,
|
||||||
{
|
int expectedStatus) throws PublicApiException
|
||||||
String msg = errorMessage + ": \n" +
|
{
|
||||||
" Response: " + response;
|
try
|
||||||
throw new PublicApiException(msg, response);
|
{
|
||||||
}
|
HttpResponse response = get("public", entityCollectionName, entityId, relationCollectionName, relationId, params);
|
||||||
else
|
checkStatus(errorMessage, expectedStatus, response);
|
||||||
{
|
return response;
|
||||||
return response;
|
}
|
||||||
}
|
catch (IOException e)
|
||||||
}
|
{
|
||||||
catch(IOException e)
|
throw new PublicApiException(e);
|
||||||
{
|
}
|
||||||
throw new PublicApiException(e);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpResponse getSingle(String entityCollectionName, String entityId, String relationCollectionName, String relationId, String errorMessage) throws PublicApiException
|
public HttpResponse getSingle(String entityCollectionName, String entityId, String relationCollectionName, String relationId, String errorMessage) throws PublicApiException
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user