mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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:
@@ -315,6 +315,7 @@ public interface RecognizedParamsExtractor
|
||||
{
|
||||
rpeLogger().debug("Invalid sort order definition (" + sortDef + "). Valid values are " + SortColumn.ASCENDING + " or "
|
||||
+ SortColumn.DESCENDING + ".");
|
||||
throw new InvalidArgumentException("Unknown sort order direction: "+sortDef+" expected: asc or desc");
|
||||
}
|
||||
}
|
||||
sortedColumns.add(new SortColumn(columnName, SortColumn.ASCENDING.equals(sortOrder)));
|
||||
|
@@ -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);
|
||||
@@ -148,14 +148,17 @@ public class RecognizedParamsExtractorTest implements RecognizedParamsExtractor
|
||||
assertEquals("name", theSort.get(1).column);
|
||||
assertTrue(theSort.get(1).asc);
|
||||
|
||||
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
|
||||
try
|
||||
{
|
||||
getSort("age asc, name des"); // nvalid, should be desc
|
||||
fail("Should throw an InvalidSelectException");
|
||||
}
|
||||
catch (InvalidArgumentException error)
|
||||
{
|
||||
// this is correct
|
||||
}
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user