mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
[ACS-2557] Moved test methods to more appropriate test class (#966)
This commit is contained in:
@@ -6345,95 +6345,6 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
|||||||
disableRestDirectAccessUrls();
|
disableRestDirectAccessUrls();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRequestVersionsContentDirectUrl() throws Exception
|
|
||||||
{
|
|
||||||
setRequestContext(user1);
|
|
||||||
|
|
||||||
String myNodeId = getMyNodeId();
|
|
||||||
|
|
||||||
Document d1 = new Document();
|
|
||||||
d1.setName("d1.txt");
|
|
||||||
d1.setNodeType(TYPE_CM_CONTENT);
|
|
||||||
|
|
||||||
// create *empty* text file - as of now, versioning is not enabled by default
|
|
||||||
HttpResponse response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1), 201);
|
|
||||||
Document documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
|
||||||
|
|
||||||
String docId = documentResp.getId();
|
|
||||||
assertFalse(documentResp.getAspectNames().contains("cm:versionable"));
|
|
||||||
assertNull(documentResp.getProperties()); // no properties (ie. no "cm:versionLabel")
|
|
||||||
|
|
||||||
int majorVersion = 1;
|
|
||||||
int minorVersion = 0;
|
|
||||||
|
|
||||||
String content = "The quick brown fox jumps over the lazy dog ";
|
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("comment", "my version ");
|
|
||||||
|
|
||||||
documentResp = updateTextFile(docId, content, params);
|
|
||||||
assertTrue(documentResp.getAspectNames().contains("cm:versionable"));
|
|
||||||
assertNotNull(documentResp.getProperties());
|
|
||||||
assertEquals(majorVersion+"."+minorVersion, documentResp.getProperties().get("cm:versionLabel"));
|
|
||||||
|
|
||||||
final String contentNodeId = documentResp.getId();
|
|
||||||
|
|
||||||
// Check the upload response
|
|
||||||
assertNotNull(documentResp.getProperties());
|
|
||||||
assertTrue(documentResp.getAspectNames().contains("cm:versionable"));
|
|
||||||
ContentInfo contentInfo = documentResp.getContent();
|
|
||||||
assertNotNull(contentInfo);
|
|
||||||
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, contentInfo.getMimeType());
|
|
||||||
|
|
||||||
HttpResponse dauResponse = post(getRequestContentDirectUrl(contentNodeId), null, null, null, null, 501);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRequestRenditionContentDirectUrl() throws Exception
|
|
||||||
{
|
|
||||||
setRequestContext(user1);
|
|
||||||
|
|
||||||
RepoService.TestNetwork networkN1;
|
|
||||||
RepoService.TestPerson userOneN1;
|
|
||||||
Site userOneN1Site;
|
|
||||||
|
|
||||||
networkN1 = repoService.createNetworkWithAlias("ping", true);
|
|
||||||
networkN1.create();
|
|
||||||
userOneN1 = networkN1.createUser();
|
|
||||||
|
|
||||||
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
|
|
||||||
|
|
||||||
String siteTitle = "RandomSite" + System.currentTimeMillis();
|
|
||||||
userOneN1Site = createSite(siteTitle, SiteVisibility.PRIVATE);
|
|
||||||
|
|
||||||
// Create a folder within the site document's library
|
|
||||||
String folderName = "folder" + System.currentTimeMillis();
|
|
||||||
String parentId = getSiteContainerNodeId(userOneN1Site.getId(), "documentLibrary");
|
|
||||||
String folder_Id = createNode(parentId, folderName, TYPE_CM_FOLDER, null).getId();
|
|
||||||
|
|
||||||
// Create multipart request - pdf file
|
|
||||||
String renditionName = "doclib";
|
|
||||||
String fileName = "quick.pdf";
|
|
||||||
File file = getResourceFile(fileName);
|
|
||||||
MultiPartRequest reqBody = MultiPartBuilder.create()
|
|
||||||
.setFileData(new FileData(fileName, file))
|
|
||||||
.setRenditions(Collections.singletonList(renditionName))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Upload quick.pdf file into 'folder' - including request to create 'doclib' thumbnail
|
|
||||||
HttpResponse response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
|
||||||
Document document = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
|
||||||
String contentNodeId = document.getId();
|
|
||||||
|
|
||||||
// wait and check that rendition is created ...
|
|
||||||
Rendition rendition = waitAndGetRendition(contentNodeId, null, renditionName);
|
|
||||||
assertNotNull(rendition);
|
|
||||||
assertEquals(Rendition.RenditionStatus.CREATED, rendition.getStatus());
|
|
||||||
|
|
||||||
HttpResponse dauResponse = post(getRequestContentDirectUrl(contentNodeId), null, null, null, null, 501);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRequestDeleteRendition() throws Exception
|
public void testRequestDeleteRendition() throws Exception
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.tests;
|
package org.alfresco.rest.api.tests;
|
||||||
|
|
||||||
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.rest.AbstractSingleNetworkSiteTest;
|
import org.alfresco.rest.AbstractSingleNetworkSiteTest;
|
||||||
import org.alfresco.rest.api.Nodes;
|
import org.alfresco.rest.api.Nodes;
|
||||||
import org.alfresco.rest.api.model.VersionOptions;
|
import org.alfresco.rest.api.model.VersionOptions;
|
||||||
@@ -33,6 +34,7 @@ import org.alfresco.rest.api.tests.client.HttpResponse;
|
|||||||
import org.alfresco.rest.api.tests.client.PublicApiClient;
|
import org.alfresco.rest.api.tests.client.PublicApiClient;
|
||||||
import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
|
import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
|
||||||
import org.alfresco.rest.api.tests.client.PublicApiHttpClient;
|
import org.alfresco.rest.api.tests.client.PublicApiHttpClient;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.ContentInfo;
|
||||||
import org.alfresco.rest.api.tests.client.data.Document;
|
import org.alfresco.rest.api.tests.client.data.Document;
|
||||||
import org.alfresco.rest.api.tests.client.data.Node;
|
import org.alfresco.rest.api.tests.client.data.Node;
|
||||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
||||||
@@ -1083,6 +1085,50 @@ public class NodeVersionsApiTest extends AbstractSingleNetworkSiteTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRequestVersionsContentDirectUrl() throws Exception
|
||||||
|
{
|
||||||
|
setRequestContext(user1);
|
||||||
|
|
||||||
|
String myNodeId = getMyNodeId();
|
||||||
|
|
||||||
|
Document d1 = new Document();
|
||||||
|
d1.setName("d1.txt");
|
||||||
|
d1.setNodeType(TYPE_CM_CONTENT);
|
||||||
|
|
||||||
|
// create *empty* text file - as of now, versioning is not enabled by default
|
||||||
|
HttpResponse response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1), 201);
|
||||||
|
Document documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||||
|
|
||||||
|
String docId = documentResp.getId();
|
||||||
|
assertFalse(documentResp.getAspectNames().contains("cm:versionable"));
|
||||||
|
assertNull(documentResp.getProperties()); // no properties (ie. no "cm:versionLabel")
|
||||||
|
|
||||||
|
int majorVersion = 1;
|
||||||
|
int minorVersion = 0;
|
||||||
|
|
||||||
|
String content = "The quick brown fox jumps over the lazy dog ";
|
||||||
|
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("comment", "my version ");
|
||||||
|
|
||||||
|
documentResp = updateTextFile(docId, content, params);
|
||||||
|
assertTrue(documentResp.getAspectNames().contains("cm:versionable"));
|
||||||
|
assertNotNull(documentResp.getProperties());
|
||||||
|
assertEquals(majorVersion+"."+minorVersion, documentResp.getProperties().get("cm:versionLabel"));
|
||||||
|
|
||||||
|
final String contentNodeId = documentResp.getId();
|
||||||
|
|
||||||
|
// Check the upload response
|
||||||
|
assertNotNull(documentResp.getProperties());
|
||||||
|
assertTrue(documentResp.getAspectNames().contains("cm:versionable"));
|
||||||
|
ContentInfo contentInfo = documentResp.getContent();
|
||||||
|
assertNotNull(contentInfo);
|
||||||
|
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, contentInfo.getMimeType());
|
||||||
|
|
||||||
|
HttpResponse dauResponse = post(getRequestVersionDirectAccessUrl(contentNodeId, majorVersion+"."+minorVersion), null, null, null, null, 501);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test version creation when updating file binary content.
|
* Test version creation when updating file binary content.
|
||||||
*
|
*
|
||||||
|
@@ -515,6 +515,51 @@ public class RenditionsTest extends AbstractBaseApiTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRequestRenditionContentDirectUrl() throws Exception
|
||||||
|
{
|
||||||
|
setRequestContext(user1);
|
||||||
|
|
||||||
|
RepoService.TestNetwork networkN1;
|
||||||
|
RepoService.TestPerson userOneN1;
|
||||||
|
Site userOneN1Site;
|
||||||
|
|
||||||
|
networkN1 = repoService.createNetworkWithAlias("ping", true);
|
||||||
|
networkN1.create();
|
||||||
|
userOneN1 = networkN1.createUser();
|
||||||
|
|
||||||
|
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
|
||||||
|
|
||||||
|
String siteTitle = "RandomSite" + System.currentTimeMillis();
|
||||||
|
userOneN1Site = createSite(siteTitle, SiteVisibility.PRIVATE);
|
||||||
|
|
||||||
|
// Create a folder within the site document's library
|
||||||
|
String folderName = "folder" + System.currentTimeMillis();
|
||||||
|
String parentId = getSiteContainerNodeId(userOneN1Site.getId(), "documentLibrary");
|
||||||
|
String folder_Id = createNode(parentId, folderName, TYPE_CM_FOLDER, null).getId();
|
||||||
|
|
||||||
|
// Create multipart request - pdf file
|
||||||
|
String renditionName = "doclib";
|
||||||
|
String fileName = "quick.pdf";
|
||||||
|
File file = getResourceFile(fileName);
|
||||||
|
MultiPartRequest reqBody = MultiPartBuilder.create()
|
||||||
|
.setFileData(new FileData(fileName, file))
|
||||||
|
.setRenditions(Collections.singletonList(renditionName))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Upload quick.pdf file into 'folder' - including request to create 'doclib' thumbnail
|
||||||
|
HttpResponse response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||||
|
Document document = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||||
|
String contentNodeId = document.getId();
|
||||||
|
|
||||||
|
// wait and check that rendition is created ...
|
||||||
|
Rendition rendition = waitAndGetRendition(contentNodeId, null, renditionName);
|
||||||
|
assertNotNull(rendition);
|
||||||
|
assertEquals(Rendition.RenditionStatus.CREATED, rendition.getStatus());
|
||||||
|
|
||||||
|
HttpResponse dauResponse = post(getRequestRenditionDirectAccessUrl(contentNodeId, renditionName), null, null, null, null, 501);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests create rendition when on upload/create of a file
|
* Tests create rendition when on upload/create of a file
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user