Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)

121614 jvonka: REST fwk - allow select clause properties to take precedence (ie. be included) when using properties 'filter'
   - eg. select=abc,def&properties=id,name, ghi ... should return all five (not just id,name,ghi)
   RA-739


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126413 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-05-10 10:50:07 +00:00
parent ca1de05fe7
commit 5474d0a70f
2 changed files with 107 additions and 5 deletions

View File

@@ -1,3 +1,21 @@
/*
* Copyright (C) 2005-2016 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.rest.framework.tests.core;
import static org.junit.Assert.assertEquals;
@@ -17,6 +35,7 @@ import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -434,7 +453,8 @@ public class SerializeTests
//this is correct
}
}
// note: exposed as "properties" query param
@Test
public void testFilter() throws IOException, JSONException
{
@@ -448,7 +468,21 @@ public class SerializeTests
res = new ExecutionResult(new Sheep("bob"),theFilter);
out = writeResponse(res);
JSONObject jsonRsp = new JSONObject(new JSONTokener(out));
assertEquals(1, jsonRsp.length());
JSONObject entry = jsonRsp.getJSONObject("entry");
assertEquals(2, entry.length());
assertEquals("The name should be 'Dolly'", "Dolly", entry.getString("name"));
assertTrue("The age should be 3", entry.getInt("age") == 3);
// unit test filter with select taking precendence
List<String> theSelect = ResourceWebScriptHelper.getSelectClause("name");
theFilter = ResourceWebScriptHelper.getFilter("age", theSelect);
res = new ExecutionResult(new Sheep("bob"),theFilter);
out = writeResponse(res);
jsonRsp = new JSONObject(new JSONTokener(out));
assertEquals(1, jsonRsp.length());
entry = jsonRsp.getJSONObject("entry");
assertEquals(2, entry.length());
assertEquals("The name should be 'Dolly'", "Dolly", entry.getString("name"));
assertTrue("The age should be 3", entry.getInt("age") == 3);
@@ -469,7 +503,6 @@ public class SerializeTests
res = helper.postProcessResponse(v3,"goat",ParamsExtender.valueOf(relFiler, "notUsed"),new SlimGoat());
out = writeResponse(res);
assertTrue("Must return only the herd name.", StringUtils.contains(out, "{\"name\":\"bigun\"}"));
}
@Test