mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
REPO-1058: REST API - minor fix for "fields" param (fka "properties") to handle field names with spaces
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130835 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -150,7 +150,7 @@ public interface RecognizedParamsExtractor
|
||||
Set<String> filteredProperties = new HashSet<String>(st.countTokens());
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
filteredProperties.add(st.nextToken());
|
||||
filteredProperties.add(st.nextToken().trim());
|
||||
}
|
||||
|
||||
// if supplied, the select takes precedence over the filter (fields/properties) for top-level bean properties
|
||||
|
@@ -520,24 +520,19 @@ public class QueriesPeopleApiTest extends AbstractSingleNetworkSiteTest
|
||||
|
||||
checkApiCall(term, orderBy, fields, paging, expectedStatus, expectedPeople);
|
||||
}
|
||||
|
||||
// // TODO Having a space in the list discards everything after the space - found in manual testing - is this a framework bug?
|
||||
// @Test
|
||||
// public void testFieldsWithSpace() throws Exception
|
||||
// {
|
||||
// fields = PARAM_FIRSTNAME+", "+PARAM_LASTNAME;
|
||||
// term = LAST_A;
|
||||
// expectedPeople = new String[]
|
||||
// {
|
||||
// "Person ["+ "lastName=LastA, ]", // USER5
|
||||
// "Person ["+"firstName=FirstA, lastName=LastA, ]", // USER1
|
||||
// "Person ["+"firstName=FirstB, lastName=LastA, ]", // USER3
|
||||
// // But is the following:
|
||||
//// "Person ["+ "]",
|
||||
//// "Person ["+"firstName=FirstA, ]",
|
||||
//// "Person ["+"firstName=FirstB, ]",
|
||||
// };
|
||||
//
|
||||
// checkApiCall(term, orderBy, fields, paging, expectedStatus, expectedPeople);
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testFieldsWithSpace() throws Exception
|
||||
{
|
||||
fields = PARAM_FIRSTNAME+", "+PARAM_LASTNAME;
|
||||
term = LAST_A;
|
||||
expectedPeople = new String[]
|
||||
{
|
||||
"Person ["+ "lastName=LastA, ]", // USER5
|
||||
"Person ["+"firstName=FirstA, lastName=LastA, ]", // USER1
|
||||
"Person ["+"firstName=FirstB, lastName=LastA, ]" // USER3
|
||||
};
|
||||
|
||||
checkApiCall(term, orderBy, fields, paging, expectedStatus, expectedPeople);
|
||||
}
|
||||
}
|
||||
|
@@ -54,26 +54,48 @@ import java.util.Map;
|
||||
*/
|
||||
public class RecognizedParamsExtractorTest implements RecognizedParamsExtractor
|
||||
{
|
||||
|
||||
|
||||
@Test
|
||||
public void getFilterTest()
|
||||
{
|
||||
BeanPropertiesFilter theFilter = getFilter(null);
|
||||
assertNotNull(theFilter);
|
||||
assertTrue("Null passed in so must return the default BeanPropertiesFilter.ALLOW_ALL class", BeanPropertiesFilter.AllProperties.class.equals(theFilter.getClass()));
|
||||
|
||||
assertTrue(theFilter.isAllowed("bob"));
|
||||
assertTrue(theFilter.isAllowed("fred"));
|
||||
assertTrue(theFilter.isAllowed("50"));
|
||||
assertTrue(theFilter.isAllowed("b.z"));
|
||||
|
||||
theFilter = getFilter("bob");
|
||||
assertNotNull(theFilter);
|
||||
assertTrue("Must return the BeanPropertiesFilter class", theFilter instanceof BeanPropertiesFilter);
|
||||
assertTrue(theFilter.isAllowed("bob"));
|
||||
assertFalse(theFilter.isAllowed("fred"));
|
||||
assertFalse(theFilter.isAllowed("50"));
|
||||
assertFalse(theFilter.isAllowed("b.z"));
|
||||
|
||||
theFilter = getFilter("50,fred,b.z");
|
||||
assertNotNull(theFilter);
|
||||
assertTrue("Must return the BeanPropertiesFilter class", theFilter instanceof BeanPropertiesFilter);
|
||||
|
||||
assertFalse(theFilter.isAllowed("bob"));
|
||||
assertTrue(theFilter.isAllowed("fred"));
|
||||
assertTrue(theFilter.isAllowed("50"));
|
||||
assertTrue(theFilter.isAllowed("b.z"));
|
||||
|
||||
theFilter = getFilter("50,fred,");
|
||||
assertNotNull(theFilter);
|
||||
assertTrue("Must return the BeanPropertiesFilter class", theFilter instanceof BeanPropertiesFilter);
|
||||
assertFalse(theFilter.isAllowed("bob"));
|
||||
assertTrue(theFilter.isAllowed("fred"));
|
||||
assertTrue(theFilter.isAllowed("50"));
|
||||
assertFalse(theFilter.isAllowed("b.z"));
|
||||
|
||||
theFilter = getFilter("50, bob, fred ,");
|
||||
assertNotNull(theFilter);
|
||||
assertTrue("Must return the BeanPropertiesFilter class", theFilter instanceof BeanPropertiesFilter);
|
||||
assertTrue(theFilter.isAllowed("bob"));
|
||||
assertTrue(theFilter.isAllowed("fred"));
|
||||
assertTrue(theFilter.isAllowed("50"));
|
||||
assertFalse(theFilter.isAllowed("b.z"));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user