mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
122978 jvonka: RA-766: Update REST fwk - implement "include" query param (used by nodes & shared-links) and deprecate "select" (still used by tasks & cmm). git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126520 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -366,7 +366,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
assertNotNull(node.getContent().getEncoding());
|
||||
assertTrue(node.getContent().getSizeInBytes() > 0);
|
||||
|
||||
// request without select
|
||||
// request without "include"
|
||||
Map<String, String> params = new HashMap<>();
|
||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
||||
@@ -378,9 +378,9 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
assertNull("There shouldn't be a 'aspectNames' object in the response.", n.getAspectNames());
|
||||
}
|
||||
|
||||
// request with select - example 1
|
||||
// request with include - example 1
|
||||
params = new HashMap<>();
|
||||
params.put("select", "isLink");
|
||||
params.put("include", "isLink");
|
||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
||||
for (Node n : nodes)
|
||||
@@ -388,9 +388,9 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
assertNotNull("There should be a 'isLink' object in the response.", n.getIsLink());
|
||||
}
|
||||
|
||||
// request with select - example 2
|
||||
// request with include - example 2
|
||||
params = new HashMap<>();
|
||||
params.put("select", "aspectNames,properties, path,isLink");
|
||||
params.put("include", "aspectNames,properties, path,isLink");
|
||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
||||
for (Node n : nodes)
|
||||
@@ -401,9 +401,9 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
assertNotNull("There should be a 'aspectNames' object in the response.", n.getAspectNames());
|
||||
}
|
||||
|
||||
// request specific property via select
|
||||
// request specific property via include
|
||||
params = new HashMap<>();
|
||||
params.put("select", "cm:lastThumbnailModification");
|
||||
params.put("include", "cm:lastThumbnailModification");
|
||||
params.put("orderBy", "isFolder DESC,modifiedAt DESC");
|
||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
||||
@@ -522,7 +522,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
/**
|
||||
* Tests get node with path information.
|
||||
* <p>GET:</p>
|
||||
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>?select=path}
|
||||
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>?include=path}
|
||||
*/
|
||||
@Test
|
||||
public void testGetPathElements_DocLib() throws Exception
|
||||
@@ -559,8 +559,8 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
// Grant userTwoN1 permission for folderC
|
||||
permissionService.setPermission(folderC_Ref, userTwoN1.getId(), PermissionService.CONSUMER, true);
|
||||
|
||||
//...nodes/nodeId?select=path
|
||||
Map<String, String> params = Collections.singletonMap("select", "path");
|
||||
//...nodes/nodeId?include=path
|
||||
Map<String, String> params = Collections.singletonMap("include", "path");
|
||||
HttpResponse response = getSingle(NodesEntityResource.class, userOneN1.getId(), content1_Id, params, 200);
|
||||
Document node = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||
PathInfo path = node.getPath();
|
||||
@@ -673,8 +673,8 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
d1.expected(documentResp);
|
||||
|
||||
// get node info + path
|
||||
//...nodes/nodeId?select=path
|
||||
Map<String, String> params = Collections.singletonMap("select", "path");
|
||||
//...nodes/nodeId?include=path
|
||||
Map<String, String> params = Collections.singletonMap("include", "path");
|
||||
response = getSingle(NodesEntityResource.class, user1, content1Id, params, 200);
|
||||
documentResp = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||
|
||||
@@ -760,7 +760,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
assertEquals(user1, node.getName());
|
||||
assertTrue(node.getIsFolder());
|
||||
assertFalse(node.getIsFile());
|
||||
assertNull(node.getPath()); // note: path can be optionally "select"'ed - see separate test
|
||||
assertNull(node.getPath()); // note: path can be optionally "include"'ed - see separate test
|
||||
|
||||
response = getSingle(NodesEntityResource.class, user1, Nodes.PATH_SHARED, null, 200);
|
||||
node = jacksonUtil.parseEntry(response.getJsonResponse(), Node.class);
|
||||
@@ -814,7 +814,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
// Default encoding
|
||||
assertEquals("UTF-8", contentInfo.getEncoding());
|
||||
// Check there is no path info returned.
|
||||
// The path info should only be returned when it is requested via a select statement.
|
||||
// The path info should only be returned when it is requested via a include statement.
|
||||
assertNull(document.getPath());
|
||||
|
||||
// Retrieve the uploaded file
|
||||
@@ -850,7 +850,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
assertEquals("quick-1.pdf", document.getName());
|
||||
|
||||
// upload the same file again, and request the path info to be present in the response
|
||||
response = post(getChildrenUrl(Nodes.PATH_MY), user1, reqBody.getBody(), "?select=path", reqBody.getContentType(), 201);
|
||||
response = post(getChildrenUrl(Nodes.PATH_MY), user1, reqBody.getBody(), "?include=path", reqBody.getContentType(), 201);
|
||||
document = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||
// Check the upload response
|
||||
assertEquals("quick-2.pdf", document.getName());
|
||||
@@ -2151,7 +2151,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
File pdfFile = getResourceFile("quick.pdf");
|
||||
payload = new BinaryPayload(pdfFile, MimetypeMap.MIMETYPE_PDF, "ISO-8859-1");
|
||||
|
||||
response = putBinary(url + "?select=path", user1, payload, null, null, 200);
|
||||
response = putBinary(url + "?include=path", user1, payload, null, null, 200);
|
||||
docResp = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||
assertEquals(docName, docResp.getName());
|
||||
assertNotNull(docResp.getContent());
|
||||
|
@@ -183,7 +183,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
||||
|
||||
|
||||
// auth access to get shared link info - as user1
|
||||
Map<String, String> params = Collections.singletonMap("select", "allowableOperations");
|
||||
Map<String, String> params = Collections.singletonMap("include", "allowableOperations");
|
||||
response = getSingle(QuickShareLinkEntityResource.class, user1, sharedId, params, 200);
|
||||
resp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class);
|
||||
|
||||
@@ -197,7 +197,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
||||
assertNull(resp.getAllowableOperations());
|
||||
|
||||
// auth access to get shared link info - as user2
|
||||
params = Collections.singletonMap("select", "allowableOperations");
|
||||
params = Collections.singletonMap("include", "allowableOperations");
|
||||
response = getSingle(QuickShareLinkEntityResource.class, user2, sharedId, params, 200);
|
||||
resp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class);
|
||||
|
||||
@@ -211,21 +211,21 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
||||
assertEquals(1, resp.getAllowableOperations().size());
|
||||
assertEquals("delete", resp.getAllowableOperations().get(0));
|
||||
|
||||
// allowable operations not selected
|
||||
// allowable operations not included
|
||||
response = getSingle(QuickShareLinkEntityResource.class, user2, sharedId, null, 200);
|
||||
resp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class);
|
||||
assertNull(resp.getAllowableOperations());
|
||||
|
||||
|
||||
// unauth access to get shared link info
|
||||
params = Collections.singletonMap("select", "allowableOperations"); // note: this will be ignore for unauth access
|
||||
params = Collections.singletonMap("include", "allowableOperations"); // note: this will be ignore for unauth access
|
||||
response = getSingle(QuickShareLinkEntityResource.class, null, sharedId, params, 200);
|
||||
resp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class);
|
||||
|
||||
assertEquals(sharedId, resp.getId());
|
||||
assertEquals(docName1, resp.getName());
|
||||
assertNull(resp.getNodeId()); // nodeId not returned
|
||||
assertNull(resp.getAllowableOperations()); // select is ignored
|
||||
assertNull(resp.getAllowableOperations()); // include is ignored
|
||||
|
||||
assertNull(resp.getModifiedByUser().getId()); // userId not returned
|
||||
assertEquals(user1+" "+user1, resp.getModifiedByUser().getDisplayName());
|
||||
|
@@ -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.mockito.Matchers.any;
|
||||
@@ -51,7 +69,7 @@ public abstract class AbstractContextTest
|
||||
JacksonHelper jsonHelper;
|
||||
|
||||
static Params NOT_USED = Params.valueOf("notUsed", null, mock(WebScriptRequest.class));
|
||||
static final Params.RecognizedParams NULL_PARAMS = new Params.RecognizedParams(null, null, null, null, null, null, null, false);
|
||||
static final Params.RecognizedParams NULL_PARAMS = new Params.RecognizedParams(null, null, null, null, null, null, null, null, false);
|
||||
static final WithResponse callBack = new WithResponse(Status.STATUS_OK, ApiWebScript.DEFAULT_JSON_CONTENT,ApiWebScript.CACHE_NEVER);
|
||||
static Api api = Api.valueOf("alfrescomock", "private", "1");
|
||||
|
||||
|
@@ -25,22 +25,22 @@ public class ParamsExtender extends Params
|
||||
|
||||
public static Params valueOf(Map<String, BeanPropertiesFilter> rFilter, String entityId)
|
||||
{
|
||||
return new ParamsExtender(entityId, null, null, null, null, new Params.RecognizedParams(null, null, null, rFilter, null, null, null, false));
|
||||
return new ParamsExtender(entityId, null, null, null, null, new Params.RecognizedParams(null, null, null, rFilter, null, null, null, null, false));
|
||||
}
|
||||
|
||||
public static Params valueOf(boolean includeSource, String entityId)
|
||||
{
|
||||
return new ParamsExtender(entityId, null, null, null, null, new Params.RecognizedParams(null, null, null, null, null, null, null, includeSource));
|
||||
return new ParamsExtender(entityId, null, null, null, null, new Params.RecognizedParams(null, null, null, null, null, null, null, null, includeSource));
|
||||
}
|
||||
|
||||
public static Params valueOf(Paging paging, String entityId)
|
||||
{
|
||||
return new ParamsExtender(entityId, null, null, null, null, new Params.RecognizedParams(null, paging, null, null, null, null, null, false));
|
||||
return new ParamsExtender(entityId, null, null, null, null, new Params.RecognizedParams(null, paging, null, null, null, null, null, null, false));
|
||||
}
|
||||
|
||||
public static Params valueOf(Map<String, String[]> params)
|
||||
{
|
||||
return new ParamsExtender(null, null, null, null, null, new Params.RecognizedParams(params, null, null, null, null, null, null, false));
|
||||
return new ParamsExtender(null, null, null, null, null, new Params.RecognizedParams(params, null, null, null, null, null, null, null, false));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
@@ -146,16 +164,28 @@ public class ResourceWebScriptHelperTests
|
||||
assertTrue(theSort.get(0).asc);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIncludeClauseTest()
|
||||
{
|
||||
getClauseTest("include");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSelectClauseTest()
|
||||
{
|
||||
List<String> theSelect = ResourceWebScriptHelper.getSelectClause(null);
|
||||
assertNotNull(theSelect);
|
||||
assertFalse("Null passed in so nothing in the Select.",theSelect.size() > 0);
|
||||
getClauseTest("select");
|
||||
}
|
||||
|
||||
// at the moment select and include are parsed the same way, hence common/shared test
|
||||
private void getClauseTest(String paramName)
|
||||
{
|
||||
List<String> theClause = getClause(paramName, null);
|
||||
assertNotNull(theClause);
|
||||
assertFalse("Null passed in so nothing in the "+paramName, theClause.size() > 0);
|
||||
|
||||
try
|
||||
{
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause(",,,");
|
||||
theClause = getClause(paramName, ",,,");
|
||||
fail("Should throw an InvalidSelectException");
|
||||
}
|
||||
catch (InvalidSelectException error)
|
||||
@@ -165,7 +195,7 @@ public class ResourceWebScriptHelperTests
|
||||
|
||||
try
|
||||
{
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("(,,,");
|
||||
theClause = getClause(paramName, "(,,,");
|
||||
fail("Should throw an InvalidSelectException");
|
||||
}
|
||||
catch (InvalidSelectException error)
|
||||
@@ -175,7 +205,7 @@ public class ResourceWebScriptHelperTests
|
||||
|
||||
try
|
||||
{
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("(,,,)");
|
||||
theClause = getClause(paramName, "(,,,)");
|
||||
fail("Should throw an InvalidSelectException");
|
||||
}
|
||||
catch (InvalidSelectException error)
|
||||
@@ -185,7 +215,7 @@ public class ResourceWebScriptHelperTests
|
||||
|
||||
try
|
||||
{
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("x/,z");
|
||||
theClause = getClause(paramName, "x/,z");
|
||||
fail("Should throw an InvalidSelectException");
|
||||
}
|
||||
catch (InvalidArgumentException error)
|
||||
@@ -195,7 +225,7 @@ public class ResourceWebScriptHelperTests
|
||||
|
||||
try
|
||||
{
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/x'n,/z");
|
||||
theClause = getClause(paramName, "/x'n,/z");
|
||||
fail("Should throw an InvalidSelectException");
|
||||
}
|
||||
catch (InvalidArgumentException error)
|
||||
@@ -205,7 +235,7 @@ public class ResourceWebScriptHelperTests
|
||||
|
||||
try
|
||||
{
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/foo/0");
|
||||
theClause = getClause(paramName, "/foo/0");
|
||||
fail("Should throw an InvalidSelectException. Legal identifiers must start with a letter not zero");
|
||||
}
|
||||
catch (InvalidArgumentException error)
|
||||
@@ -215,7 +245,7 @@ public class ResourceWebScriptHelperTests
|
||||
|
||||
try
|
||||
{
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/");
|
||||
theClause = getClause(paramName, "/");
|
||||
fail("Should throw an InvalidSelectException. No identifier specified.");
|
||||
}
|
||||
catch (InvalidArgumentException error)
|
||||
@@ -223,56 +253,71 @@ public class ResourceWebScriptHelperTests
|
||||
//this is correct
|
||||
}
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("king/kong");
|
||||
assertTrue("has a valid select",theSelect.size() == 1);
|
||||
assertEquals("king/kong",theSelect.get(0));
|
||||
theClause = getClause(paramName, "king/kong");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 1);
|
||||
assertEquals("king/kong",theClause.get(0));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("x,y");
|
||||
assertTrue("has a valid select",theSelect.size() == 2);
|
||||
assertEquals("x",theSelect.get(0));
|
||||
assertEquals("y",theSelect.get(1));
|
||||
theClause = getClause(paramName, "x,y");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 2);
|
||||
assertEquals("x",theClause.get(0));
|
||||
assertEquals("y",theClause.get(1));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("x,/z");
|
||||
assertTrue("has a valid select",theSelect.size() == 2);
|
||||
assertEquals("x",theSelect.get(0));
|
||||
assertEquals("/z",theSelect.get(1));
|
||||
theClause = getClause(paramName, "x,/z");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 2);
|
||||
assertEquals("x",theClause.get(0));
|
||||
assertEquals("/z",theClause.get(1));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/b");
|
||||
assertTrue("has a valid select",theSelect.size() == 1);
|
||||
assertEquals("/b",theSelect.get(0));
|
||||
theClause = getClause(paramName, "/b");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 1);
|
||||
assertEquals("/b",theClause.get(0));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/be,/he");
|
||||
assertTrue("has a valid select",theSelect.size() == 2);
|
||||
assertEquals("/be",theSelect.get(0));
|
||||
assertEquals("/he",theSelect.get(1));
|
||||
theClause = getClause(paramName, "/be,/he");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 2);
|
||||
assertEquals("/be",theClause.get(0));
|
||||
assertEquals("/he",theClause.get(1));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/king/kong");
|
||||
assertTrue("has a valid select",theSelect.size() == 1);
|
||||
assertEquals("/king/kong",theSelect.get(0));
|
||||
theClause = getClause(paramName, "/king/kong");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 1);
|
||||
assertEquals("/king/kong",theClause.get(0));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/name,/person/age");
|
||||
assertTrue("has a valid select",theSelect.size() == 2);
|
||||
assertEquals("/name",theSelect.get(0));
|
||||
assertEquals("/person/age",theSelect.get(1));
|
||||
theClause = getClause(paramName, "/name,/person/age");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 2);
|
||||
assertEquals("/name",theClause.get(0));
|
||||
assertEquals("/person/age",theClause.get(1));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/foo");
|
||||
assertTrue("has a valid select",theSelect.size() == 1);
|
||||
assertEquals("/foo",theSelect.get(0));
|
||||
theClause = getClause(paramName, "/foo");
|
||||
assertTrue("has a valid select",theClause.size() == 1);
|
||||
assertEquals("/foo",theClause.get(0));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/foo/anArray/x");
|
||||
assertTrue("has a valid select",theSelect.size() == 1);
|
||||
assertEquals("/foo/anArray/x",theSelect.get(0));
|
||||
theClause = getClause(paramName, "/foo/anArray/x");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 1);
|
||||
assertEquals("/foo/anArray/x",theClause.get(0));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/foo/anArray/x,/person/age,/eggs/bacon/sausage,/p");
|
||||
assertTrue("has a valid select",theSelect.size() == 4);
|
||||
assertEquals("/foo/anArray/x",theSelect.get(0));
|
||||
assertEquals("/person/age",theSelect.get(1));
|
||||
assertEquals("/eggs/bacon/sausage",theSelect.get(2));
|
||||
assertEquals("/p",theSelect.get(3));
|
||||
theClause = getClause(paramName, "/foo/anArray/x,/person/age,/eggs/bacon/sausage,/p");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 4);
|
||||
assertEquals("/foo/anArray/x",theClause.get(0));
|
||||
assertEquals("/person/age",theClause.get(1));
|
||||
assertEquals("/eggs/bacon/sausage",theClause.get(2));
|
||||
assertEquals("/p",theClause.get(3));
|
||||
|
||||
theSelect = ResourceWebScriptHelper.getSelectClause("/foo/_bar ");
|
||||
assertTrue("has a valid select",theSelect.size() == 1);
|
||||
assertEquals("/foo/_bar",theSelect.get(0));
|
||||
theClause = getClause(paramName, "/foo/_bar ");
|
||||
assertTrue("has a valid "+paramName, theClause.size() == 1);
|
||||
assertEquals("/foo/_bar",theClause.get(0));
|
||||
}
|
||||
|
||||
private List<String> getClause(String paramName, String paramValue)
|
||||
{
|
||||
if (paramName.equalsIgnoreCase("include"))
|
||||
{
|
||||
return ResourceWebScriptHelper.getIncludeClause(paramValue);
|
||||
}
|
||||
else if (paramName.equalsIgnoreCase("select"))
|
||||
{
|
||||
return ResourceWebScriptHelper.getSelectClause(paramValue);
|
||||
}
|
||||
|
||||
fail("Unexpected clause: "+paramName);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -21,39 +21,26 @@ package org.alfresco.rest.framework.tests.core;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.api.tests.util.MultiPartBuilder;
|
||||
import org.alfresco.rest.api.tests.util.MultiPartBuilder.FileData;
|
||||
import org.alfresco.rest.api.tests.util.MultiPartBuilder.MultiPartRequest;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.core.ResourceDictionaryBuilder;
|
||||
import org.alfresco.rest.framework.core.ResourceLookupDictionary;
|
||||
import org.alfresco.rest.framework.core.ResourceWithMetadata;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
import org.alfresco.rest.framework.jacksonextensions.BeanPropertiesFilter;
|
||||
import org.alfresco.rest.framework.jacksonextensions.ExecutionResult;
|
||||
import org.alfresco.rest.framework.jacksonextensions.JacksonHelper;
|
||||
import org.alfresco.rest.framework.jacksonextensions.JacksonHelper.Writer;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction.Read;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction.ReadById;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryProperty;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.content.ContentInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||
@@ -66,7 +53,6 @@ import org.alfresco.rest.framework.tests.api.mocks3.SlimGoat;
|
||||
import org.alfresco.rest.framework.webscripts.AbstractResourceWebScript;
|
||||
import org.alfresco.rest.framework.webscripts.ResourceWebScriptHelper;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -78,21 +64,12 @@ import org.codehaus.jackson.schema.JsonSchema;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.extensions.webscripts.Format;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@@ -467,9 +444,9 @@ public class SerializeTests extends AbstractContextTest
|
||||
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);
|
||||
// unit test filter with "include" taking precendence over "fields" filter
|
||||
List<String> theInclude = ResourceWebScriptHelper.getIncludeClause("name");
|
||||
theFilter = ResourceWebScriptHelper.getFilter("age", theInclude);
|
||||
res = new ExecutionResult(new Sheep("bob"),theFilter);
|
||||
out = writeResponse(res);
|
||||
jsonRsp = new JSONObject(new JSONTokener(out));
|
||||
|
@@ -216,7 +216,7 @@ public class ProcessesImplTest extends TestCase
|
||||
private CollectionWithPagingInfo<ProcessInfo> queryActiveProcessesAndAssertResult(int skipCount, int maxItems)
|
||||
{
|
||||
Query query = ResourceWebScriptHelper.getWhereClause(QUERY_STATUS_ACTIVE);
|
||||
Parameters parameters = Params.valueOf(new RecognizedParams(null, Paging.valueOf(skipCount, maxItems), null, null, null, query, null, false), null, null, null);
|
||||
Parameters parameters = Params.valueOf(new RecognizedParams(null, Paging.valueOf(skipCount, maxItems), null, null, null, null, query, null, false), null, null, null);
|
||||
|
||||
CollectionWithPagingInfo<ProcessInfo> result = processes.getProcesses(parameters);
|
||||
|
||||
|
Reference in New Issue
Block a user