Merged 5.2.N (5.2.1) to HEAD (5.2)

129168 mmuller: Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1)
      128517 jvonka: REPO-874: Improve REST fwk: improve error message if a POST operation is attempted with multiple items
      - rationalise the code when handling POST for an API "operation" or POST to a collection that is marked as "allowMultiple=false"
      - they should now consistently return the same existing error message: "Only 1 entity is supported in the HTTP request body"
      - add api sanity tests to "create site", "create rating" and some of the node op's, such as "/move" & "/copy"


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129342 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alexandru Epure
2016-08-09 14:12:44 +00:00
parent 2254b1fa0e
commit c3eeea134f
4 changed files with 103 additions and 38 deletions

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.rest.api.tests;
import static org.junit.Assert.assertEquals;
@@ -59,6 +59,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.util.GUID;
import org.apache.commons.httpclient.HttpStatus;
import org.json.simple.JSONArray;
import org.junit.Test;
public class TestNodeRatings extends EnterpriseTestApi
@@ -467,6 +468,22 @@ public class TestNodeRatings extends EnterpriseTestApi
// Test Case cloud-1977
// invalid methods
{
try
{
// -ve test - cannot create multiple ratings in single POST call (unsupported)
List<NodeRating> ratings = new ArrayList<>(2);
ratings.add(new NodeRating("likes", true));
ratings.add(new NodeRating("likes", false));
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person11.getId()));
nodesProxy.create("nodes", nodeRef1.getId(), "ratings", null, JSONArray.toJSONString(ratings), "Unable to POST to multiple ratings");
fail();
}
catch(PublicApiException e)
{
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
}
// get an arbitrary rating
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person11.getId()));
ListResponse<NodeRating> resp = nodesProxy.getNodeRatings(nodeRef1.getId(), createParams(getPaging(0, Integer.MAX_VALUE), null));