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

123112 jvonka: Nodes (FileFolder) API - version options when updating/uploading (overwriting) existing content
   - add tests .. for now check version label only (pending future "list version history" + "get version" etc)
   RA-690


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126528 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-05-10 11:21:08 +00:00
parent c43cc28a2a
commit ee3a942fc7
3 changed files with 359 additions and 11 deletions

View File

@@ -345,11 +345,22 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
protected Document createTextFile(String userId, String parentId, String fileName, String textContent) throws IOException, Exception
{
return createTextFile(userId, parentId, fileName, textContent, "UTF-8", Collections.EMPTY_MAP);
return createTextFile(userId, parentId, fileName, textContent, "UTF-8", null);
}
protected Document createTextFile(String userId, String parentId, String fileName, String textContent, String encoding, Map<String,String> props) throws IOException, Exception
{
return createTextFile(userId, parentId, fileName, textContent, encoding, props, 201);
}
protected Document createTextFile(String userId, String parentId, String fileName, String textContent, String encoding, Map<String,String> props, int expectedStatus) throws IOException, Exception
{
if (props == null)
{
props = Collections.EMPTY_MAP;
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(textContent.getBytes());
File txtFile = TempFileProvider.createTempFile(inputStream, getClass().getSimpleName(), ".txt");
@@ -358,7 +369,23 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
.setProperties(props)
.build();
HttpResponse response = post(getNodeChildrenUrl(parentId), userId, reqBody.getBody(), null, reqBody.getContentType(), 201);
HttpResponse response = post(getNodeChildrenUrl(parentId), userId, reqBody.getBody(), null, reqBody.getContentType(), expectedStatus);
if (response.getJsonResponse().get("error") != null)
{
return null;
}
return RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
}
protected Document updateTextFile(String userId, String contentId, String textContent, Map<String,String> parameters) throws IOException, Exception
{
ByteArrayInputStream inputStream = new ByteArrayInputStream(textContent.getBytes());
File txtFile = TempFileProvider.createTempFile(inputStream, getClass().getSimpleName(), ".txt");
BinaryPayload payload = new BinaryPayload(txtFile, MimetypeMap.MIMETYPE_TEXT_PLAIN);
HttpResponse response = putBinary(getNodeContentUrl(contentId), userId, payload, null, parameters, 200);
return RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
}