Merged 5.2.N (5.2.1) to HEAD (5.2)

129192 mmuller: Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1)
      129037 adavis: REPO-243 People Live Search
         - Added another orderBy test following a question from Jan.
         - Minor change in post order code to replace a Map lookup with a List lookup. Logically the same but faster.
         - Replaced a NPE test failure with a failure message if TEST_COUNT is too small


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129366 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alexandru Epure
2016-08-09 14:16:32 +00:00
parent 175bda1980
commit 139f3137b4
2 changed files with 27 additions and 4 deletions

View File

@@ -556,9 +556,10 @@ public class QueriesImpl implements Queries, InitializingBean
public int compare(NodeRef n1, NodeRef n2) public int compare(NodeRef n1, NodeRef n2)
{ {
int result = 0; int result = 0;
for (SortColumn sortCol : sortCols) for (int i=0; i<sortCols.size(); i++)
{ {
QName sortPropQName = sortParamsToQNames.get(sortCol.column); SortColumn sortCol = sortCols.get(i);
QName sortPropQName = sortPropQNames.get(i);
Serializable p1 = getProperty(n1, sortPropQName); Serializable p1 = getProperty(n1, sortPropQName);
Serializable p2 = getProperty(n2, sortPropQName); Serializable p2 = getProperty(n2, sortPropQName);

View File

@@ -25,8 +25,11 @@
*/ */
package org.alfresco.rest.api.tests; package org.alfresco.rest.api.tests;
import static org.alfresco.rest.api.Queries.PARAM_FIRSTNAME;
import static org.alfresco.rest.api.Queries.PARAM_LASTNAME;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.alfresco.rest.api.Queries.*; import static org.junit.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -64,7 +67,7 @@ public class QueriesPeopleApiTest extends AbstractSingleNetworkSiteTest
// deleting users is hard from from static methods. For the moment do it // deleting users is hard from from static methods. For the moment do it
// in the first and last tests, but we have to get the TEST count right! // in the first and last tests, but we have to get the TEST count right!
// If we don't, a test fails or the users get left behind (not too bad). // If we don't, a test fails or the users get left behind (not too bad).
private static int TEST_COUNT = 12; private static int TEST_COUNT = 13;
private static int testCounter = 0; private static int testCounter = 0;
// Test usernames // Test usernames
@@ -274,6 +277,10 @@ public class QueriesPeopleApiTest extends AbstractSingleNetworkSiteTest
for (String id: testUserIds) for (String id: testUserIds)
{ {
Person person = testUsers.get(id); Person person = testUsers.get(id);
if (person == null)
{
fail("Did not find test Person "+id+" Check TEST_COUNT has the correct number of tests.");
}
String string = person.toString(); String string = person.toString();
list.add(string); list.add(string);
} }
@@ -382,6 +389,21 @@ public class QueriesPeopleApiTest extends AbstractSingleNetworkSiteTest
checkApiCall(term, orderBy, fields, paging, expectedStatus, expectedPeople); checkApiCall(term, orderBy, fields, paging, expectedStatus, expectedPeople);
} }
@Test
public void testOrderbyDescAndDesc() throws Exception
{
// 4 C
// 3 B A
// 2 A B
// 1 A A
// 6 C
// 5 A
orderBy = "firstName desc, lastName desc";
expectedPeople = expectedPeople(USER4, USER3, USER2, USER1, USER6, USER5);
checkApiCall(term, orderBy, fields, paging, expectedStatus, expectedPeople);
}
@Test @Test
public void testBadOrderByField() throws Exception public void testBadOrderByField() throws Exception
{ {