diff --git a/source/test-java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java b/source/test-java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java
index dcbdb83e49..e450d9388e 100644
--- a/source/test-java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java
+++ b/source/test-java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java
@@ -102,6 +102,15 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
return response;
}
+ protected HttpResponse post(String runAsUser, String entityCollectionName, String entityId, String relationCollectionName, byte[] body, String queryString, String contentType, int expectedStatus) throws Exception
+ {
+ publicApiClient.setRequestContext(new RequestContext(runAsUser));
+ HttpResponse response = publicApiClient.post(getScope(), entityCollectionName, entityId, relationCollectionName, null, body, contentType);
+ checkStatus(expectedStatus, response.getStatusCode());
+
+ return response;
+ }
+
protected HttpResponse getAll(String url, String runAsUser, PublicApiClient.Paging paging, int expectedStatus) throws Exception
{
return getAll(url, runAsUser, paging, null, expectedStatus);
diff --git a/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java b/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java
index f6781e53e2..4e35b4805a 100644
--- a/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java
+++ b/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java
@@ -1165,6 +1165,58 @@ public class NodeApiTest extends AbstractBaseApiTest
put("nodes", user2, f1Id, toJsonAsStringNonNull(dUpdate), null, 403);
}
+ /**
+ * Tests copy (file or folder)
+ *
PUT:
+ * {@literal :/alfresco/api/-default-/public/alfresco/versions/1/nodes//copy}
+ */
+ @Test
+ public void testCopy() throws Exception
+ {
+ AuthenticationUtil.setFullyAuthenticatedUser(user1);
+
+ // create folder
+ Folder folderResp = createFolder(user1, Nodes.PATH_MY, "fsource");
+ String source = folderResp.getId();
+ NodeRef sourceRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, source);
+
+ // create folder
+ folderResp = createFolder(user1, Nodes.PATH_MY, "ftarget");
+ String target = folderResp.getId();
+ NodeRef targetRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, target);
+
+ // create doc d1
+ String d1Name = "content" + System.currentTimeMillis() + "_1";
+ NodeRef d1Ref = repoService.createDocument(sourceRef, d1Name, "The quick brown fox jumps over the lazy dog.");
+ String d1Id = d1Ref.getId();
+
+ // create doc d2
+ String d2Name = "content" + System.currentTimeMillis() + "_2";
+ NodeRef d2Ref = repoService.createDocument(sourceRef, d2Name, "The quick brown fox jumps over the lazy dog 2.");
+ String d2Id = d2Ref.getId();
+
+ Map body = new HashMap<>();
+ body.put("targetParentId", target);
+
+ HttpResponse response = post(user1, "nodes", d1Id, "copy", toJsonAsStringNonNull(body).getBytes(), null, null, 201);
+ Document documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
+
+ assertEquals(d1Name, documentResp.getName());
+ assertEquals(target, documentResp.getParentId());
+
+ // copy file (with rename)
+ String newD2Name = d2Name + " updated !!";
+
+ body = new HashMap<>();
+ body.put("targetParentId", target);
+ body.put("name", newD2Name);
+
+ response = post(user1, "nodes", d2Id, "copy", toJsonAsStringNonNull(body).getBytes(), null, null, 201);
+ documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
+
+ assertEquals(newD2Name, documentResp.getName());
+ assertEquals(target, documentResp.getParentId());
+ }
/**
* Tests create folder.
* POST: