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)
129130 mmuller: Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1) 128162 jvonka: V1 REST API: Node Version History - initial api tests - REPO-313: list version history - REPO-327: get version info - REPO-229: download version content git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129324 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -3186,155 +3186,6 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
// TODO add tests to also check version comment (when we can list version history)
|
||||
}
|
||||
|
||||
/**
|
||||
* Test version creation when uploading files (via multi-part/form-data with overwrite=true)
|
||||
*
|
||||
* TODO also relates to future v1 api to list version history, etc
|
||||
*
|
||||
* <p>POST:</p>
|
||||
* {@literal <host>:<port>/alfresco/api/-default-/public/alfresco/versions/1/nodes/<nodeId>/children}
|
||||
*/
|
||||
@Test
|
||||
public void testUploadFileVersionCreate() throws Exception
|
||||
{
|
||||
String myNodeId = getMyNodeId(user1);
|
||||
|
||||
int cnt = 1;
|
||||
|
||||
int majorVersion = 1;
|
||||
int minorVersion = 0;
|
||||
|
||||
// Upload text file - versioning is currently auto enabled on upload (create file via multi-part/form-data)
|
||||
|
||||
String contentName = "content " + System.currentTimeMillis();
|
||||
String content = "The quick brown fox jumps over the lazy dog "+cnt;
|
||||
|
||||
Document documentResp = createTextFile(user1, myNodeId, contentName, content, "UTF-8", null);
|
||||
String docId = documentResp.getId();
|
||||
assertTrue(documentResp.getAspectNames().contains("cm:versionable"));
|
||||
assertNotNull(documentResp.getProperties());
|
||||
assertEquals(majorVersion+"."+minorVersion, documentResp.getProperties().get("cm:versionLabel"));
|
||||
|
||||
Map<String, String> params = null;
|
||||
|
||||
// Upload text file with same name - with overwrite=true
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
cnt++;
|
||||
minorVersion++;
|
||||
|
||||
content = "The quick brown fox jumps over the lazy dog " + cnt;
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("overwrite", "true");
|
||||
|
||||
documentResp = createTextFile(user1, myNodeId, contentName, content, "UTF-8", params);
|
||||
assertTrue(documentResp.getAspectNames().contains("cm:versionable"));
|
||||
assertNotNull(documentResp.getProperties());
|
||||
assertEquals(majorVersion+"."+minorVersion, documentResp.getProperties().get("cm:versionLabel"));
|
||||
}
|
||||
|
||||
minorVersion = 0;
|
||||
|
||||
// Updates - major versions
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
cnt++;
|
||||
majorVersion++;
|
||||
|
||||
content = "The quick brown fox jumps over the lazy dog "+cnt;
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("overwrite", "true");
|
||||
params.put("comment", "my version "+cnt);
|
||||
params.put("majorVersion", "true");
|
||||
|
||||
documentResp = createTextFile(user1, myNodeId, contentName, content, "UTF-8", params);
|
||||
assertTrue(documentResp.getAspectNames().contains("cm:versionable"));
|
||||
assertNotNull(documentResp.getProperties());
|
||||
assertEquals(majorVersion+"."+minorVersion, documentResp.getProperties().get("cm:versionLabel"));
|
||||
}
|
||||
|
||||
// Updates - minor versions
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
cnt++;
|
||||
minorVersion++;
|
||||
|
||||
content = "The quick brown fox jumps over the lazy dog "+cnt;
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("overwrite", "true");
|
||||
params.put("comment", "my version "+cnt);
|
||||
params.put("majorVersion", "false");
|
||||
|
||||
documentResp = createTextFile(user1, myNodeId, contentName, content, "UTF-8", params);
|
||||
assertTrue(documentResp.getAspectNames().contains("cm:versionable"));
|
||||
assertNotNull(documentResp.getProperties());
|
||||
assertEquals(majorVersion+"."+minorVersion, documentResp.getProperties().get("cm:versionLabel"));
|
||||
}
|
||||
|
||||
// Update again - as another major version
|
||||
cnt++;
|
||||
majorVersion++;
|
||||
minorVersion = 0;
|
||||
|
||||
content = "The quick brown fox jumps over the lazy dog "+cnt;
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("overwrite", "true");
|
||||
params.put("majorVersion", "true");
|
||||
|
||||
documentResp = createTextFile(user1, myNodeId, contentName, content, "UTF-8", params);
|
||||
assertEquals(majorVersion+"."+minorVersion, documentResp.getProperties().get("cm:versionLabel"));
|
||||
|
||||
// Update again - as another (minor) version
|
||||
cnt++;
|
||||
minorVersion++;
|
||||
|
||||
content = "The quick brown fox jumps over the lazy dog "+cnt;
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("overwrite", "true");
|
||||
|
||||
documentResp = createTextFile(user1, myNodeId, contentName, content, "UTF-8", params);
|
||||
assertEquals(majorVersion+"."+minorVersion, documentResp.getProperties().get("cm:versionLabel"));
|
||||
|
||||
|
||||
// -ve test
|
||||
params = new HashMap<>();
|
||||
params.put("overwrite", "true");
|
||||
params.put("autorename", "true");
|
||||
|
||||
createTextFile(user1, myNodeId, contentName, content, "UTF-8", params, 400);
|
||||
|
||||
|
||||
// Remove versionable aspect
|
||||
List<String> aspectNames = documentResp.getAspectNames();
|
||||
aspectNames.remove("cm:versionable");
|
||||
Document dUpdate = new Document();
|
||||
dUpdate.setAspectNames(aspectNames);
|
||||
|
||||
HttpResponse response = put(URL_NODES, user1, docId, toJsonAsStringNonNull(dUpdate), null, 200);
|
||||
documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
assertFalse(documentResp.getAspectNames().contains("cm:versionable"));
|
||||
assertNull(documentResp.getProperties()); // no properties (ie. no "cm:versionLabel")
|
||||
|
||||
|
||||
// TODO review consistency - for example, we do allow update binary content (after removing versionable)
|
||||
// -ve test - do not allow overwrite (using POST upload) if the file is not versionable
|
||||
|
||||
cnt++;
|
||||
content = "The quick brown fox jumps over the lazy dog "+cnt;
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("overwrite", "true");
|
||||
|
||||
createTextFile(user1, myNodeId, contentName, content, "UTF-8", params, 409);
|
||||
|
||||
// TODO add checks for version comment (eg. when we can list version history)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests download of file/content.
|
||||
* <p>GET:</p>
|
||||
|
Reference in New Issue
Block a user