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/BRANCHES/DEV/5.2.N/root@129168 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Martin Muller
2016-08-05 13:46:51 +00:00
parent 80cc7015e6
commit ed52b3a6c5
4 changed files with 103 additions and 38 deletions

View File

@@ -1659,6 +1659,17 @@ public class NodeApiTest extends AbstractBaseApiTest
publicApiClient.setRequestContext(new RequestContext("-default-", "admin", "admin"));
response = publicApiClient.post(getScope(), "nodes/"+ddNodeId+"/move", null, null, null, toJsonAsStringNonNull(tgt));
checkStatus(403, response.getStatusCode());
// -ve test - cannot move to multiple destinations in single POST call (unsupported)
List<NodeTarget> nodeDestinations = new ArrayList<>(2);
NodeTarget nodeTarget = new NodeTarget();
nodeTarget.setTargetParentId(f1Id);
nodeDestinations.add(nodeTarget);
nodeTarget = new NodeTarget();
nodeTarget.setTargetParentId(f2Id);
nodeDestinations.add(nodeTarget);
post("nodes/"+d1Id+"/move", user1, toJsonAsStringNonNull(nodeDestinations), null, 405);
}
/**
@@ -1746,6 +1757,17 @@ public class NodeApiTest extends AbstractBaseApiTest
tgt = new NodeTarget();
tgt.setTargetParentId(rootNodeId);
post("nodes/"+d1Id+"/copy", user1, toJsonAsStringNonNull(tgt), null, 403);
// -ve test - cannot copy to multiple destinations in single POST call (unsupported)
List<NodeTarget> nodeDestinations = new ArrayList<>(2);
NodeTarget nodeTarget = new NodeTarget();
nodeTarget.setTargetParentId(sourceId);
nodeDestinations.add(nodeTarget);
nodeTarget = new NodeTarget();
nodeTarget.setTargetParentId(targetId);
nodeDestinations.add(nodeTarget);
post("nodes/"+d1Id+"/copy", user1, toJsonAsStringNonNull(nodeDestinations), null, 405);
}
@Test