mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
129184 mmuller: 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/HEAD/root@129358 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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<>();
|
||||
|
Reference in New Issue
Block a user