Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1)

128681 jvonka: V1 REST API: version history - add api sanity check for auto-version on metadata-only updates
   REPO-348, REPO-313, REPO-905


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@129184 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Martin Muller
2016-08-05 13:47:57 +00:00
parent 2f4ee372f1
commit 79149bf9b3
5 changed files with 153 additions and 49 deletions

View File

@@ -2872,6 +2872,74 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
f1.setNodeType("app:glossary");
f1.expected(folderResp);
{
// test versioning for metadata-only updates
Map params = new HashMap<>();
params.put("majorVersion", "true");
params.put("comment", "Initial empty file :-)");
String fileName = "My File";
Node nodeResp = createEmptyTextFile(f0Id, fileName, params, 201);
assertEquals("1.0", nodeResp.getProperties().get("cm:versionLabel"));
props = new HashMap<>();
props.put("cm:title", "my file title");
dUpdate = new Document();
dUpdate.setProperties(props);
response = put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 200);
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
assertEquals("1.0", nodeResp.getProperties().get("cm:versionLabel"));
// turn-off auto-version on metadata-only updates (OOTB this is now false by default, as per MNT-12226)
props = new HashMap<>();
props.put("cm:autoVersionOnUpdateProps", true);
dUpdate = new Document();
dUpdate.setProperties(props);
response = put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 200);
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
assertEquals("1.1", nodeResp.getProperties().get("cm:versionLabel"));
props = new HashMap<>();
props.put("cm:title","my file title 2");
dUpdate = new Document();
dUpdate.setProperties(props);
response = put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 200);
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
assertEquals("1.2", nodeResp.getProperties().get("cm:versionLabel"));
props = new HashMap<>();
props.put("cm:title","my file title 3");
dUpdate = new Document();
dUpdate.setProperties(props);
response = put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 200);
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
assertEquals("1.3", nodeResp.getProperties().get("cm:versionLabel"));
// turn-off auto-version on metadata-only updates
props = new HashMap<>();
props.put("cm:autoVersionOnUpdateProps", false);
dUpdate = new Document();
dUpdate.setProperties(props);
response = put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 200);
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
assertEquals("1.3", nodeResp.getProperties().get("cm:versionLabel"));
props = new HashMap<>();
props.put("cm:title","my file title 4");
dUpdate = new Document();
dUpdate.setProperties(props);
response = put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 200);
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
assertEquals("1.3", nodeResp.getProperties().get("cm:versionLabel"));
}
// -ve test - fail on unknown property
props = new HashMap<>();