REPO-1059: REST API: Invalid orderBy field direction is ignored (hence defaults to ascending rather than returning an error)

- implement fix & update test
- note: InvalidArgumentException maps to HTTP 400
- note: we already have tests for case-insensitive (ie. we allow ASC, Asc, AsC, DESC, Desc, DeSC, or similar)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130555 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2016-09-12 11:17:04 +00:00
parent dd1aebb5ef
commit 566179e8b2
2 changed files with 13 additions and 9 deletions

View File

@@ -139,7 +139,7 @@ public class RecognizedParamsExtractorTest implements RecognizedParamsExtractor
assertEquals("age", theSort.get(1).column);
assertTrue(!theSort.get(1).asc); //desc
theSort = getSort("age Desc, name Asc");
theSort = getSort("age DeSc, name AsC");
assertNotNull(theSort);
assertTrue("Must have a value for column: NAME", !theSort.isEmpty());
assertTrue(theSort.size() == 2);
@@ -147,15 +147,18 @@ public class RecognizedParamsExtractorTest implements RecognizedParamsExtractor
assertTrue(!theSort.get(0).asc); //desc
assertEquals("name", theSort.get(1).column);
assertTrue(theSort.get(1).asc);
try
{
getSort("age asc, name des"); // nvalid, should be desc
fail("Should throw an InvalidSelectException");
}
catch (InvalidArgumentException error)
{
// this is correct
}
theSort = getSort("name des"); //invalid, should be desc
assertNotNull(theSort);
assertTrue("Must have a value for column: NAME", !theSort.isEmpty());
assertTrue(theSort.size() == 1);
assertEquals("name", theSort.get(0).column);
assertTrue(theSort.get(0).asc); //Defaults to ascending because the sort order was invalid
theSort = getSort("name asc,"); //invalid, should be desc
theSort = getSort("name asc,"); // trailing comma is ignored
assertNotNull(theSort);
assertTrue("Must have a value for column: NAME", !theSort.isEmpty());
assertTrue(theSort.size() == 1);