From c096c60c22aeee1202f23b4b6789a88ddcd3ef71 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Tue, 17 Jan 2017 14:22:24 +0000 Subject: [PATCH] Merged mward/5.2.n-repo-1583-groupmem (5.2.1) to 5.2.N (5.2.1) 134379 mward: REPO-1583: added tests for sorting git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@134402 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/rest/api/tests/GroupsTest.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/source/test-java/org/alfresco/rest/api/tests/GroupsTest.java b/source/test-java/org/alfresco/rest/api/tests/GroupsTest.java index 3cc4e13dab..90db4c9850 100644 --- a/source/test-java/org/alfresco/rest/api/tests/GroupsTest.java +++ b/source/test-java/org/alfresco/rest/api/tests/GroupsTest.java @@ -586,6 +586,51 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest { getGroupsByPersonId(personAlice.getId(), getPaging(-1, null), null, HttpServletResponse.SC_BAD_REQUEST); } + + // orderBy=sortColumn should be the same to orderBy=sortColumn ASC + { + // paging + Paging paging = getPaging(0, Integer.MAX_VALUE); + + Map otherParams = new HashMap<>(); + + // Default order. + addOrderBy(otherParams, org.alfresco.rest.api.Groups.PARAM_DISPLAY_NAME, null); + + ListResponse resp = getGroupsByPersonId(personAlice.getId(), paging, otherParams); + List groups = resp.getList(); + assertTrue("groups order not valid", groups.indexOf(groupA) < groups.indexOf(groupB)); + + // Ascending order. + addOrderBy(otherParams, org.alfresco.rest.api.Groups.PARAM_DISPLAY_NAME, true); + ListResponse respOrderAsc = getGroupsByPersonId(personAlice.getId(), paging, otherParams); + checkList(respOrderAsc.getList(), resp.getPaging(), resp); + } + + // Sort by id. + { + // paging + Paging paging = getPaging(0, Integer.MAX_VALUE); + + Map otherParams = new HashMap<>(); + addOrderBy(otherParams, org.alfresco.rest.api.Groups.PARAM_ID, false); + + // list sites + ListResponse resp = getGroupsByPersonId(personAlice.getId(), paging, otherParams); + + List groups = resp.getList(); + assertTrue("groups order not valid", groups.indexOf(groupB) < groups.indexOf(groupA)); + } + + // Multiple sort fields not allowed. + { + // paging + Paging paging = getPaging(0, Integer.MAX_VALUE); + Map otherParams = new HashMap<>(); + otherParams.put("orderBy", org.alfresco.rest.api.Groups.PARAM_ID + " ASC," + org.alfresco.rest.api.Groups.PARAM_DISPLAY_NAME + " ASC"); + + getGroupsByPersonId(personAlice.getId(), paging, otherParams, HttpServletResponse.SC_BAD_REQUEST); + } } private void testGetGroupMembersByGroupId() throws Exception