mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
123046 jvonka: Update API tests for - tweaks for common code, also check that Last-Modified and Expires are not null when downloading file content/rendition RA-641, RA-676, RA-829, RA-830 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126523 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -120,7 +120,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
Paging paging = getPaging(0, 50);
|
||||
// List all available renditions (includes those that have been created and those that are yet to be created)
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, 200);
|
||||
List<Rendition> renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertTrue(renditions.size() >= 5);
|
||||
Rendition docLib = getRendition(renditions, "doclib");
|
||||
@@ -137,13 +137,13 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
Map<String, String> params = new HashMap<>(1);
|
||||
params.put("where", "(status='NOT_CREATED')");
|
||||
// List only the NOT_CREATED renditions
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertTrue(renditions.size() >= 5);
|
||||
|
||||
params.put("where", "(status='CREATED')");
|
||||
// List only the CREATED renditions
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertEquals("There is no rendition created yet.", 0, renditions.size());
|
||||
|
||||
@@ -151,7 +151,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
// SkipCount=0,MaxItems=2
|
||||
paging = getPaging(0, 2);
|
||||
// List all available renditions
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, 200);
|
||||
renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertEquals(2, renditions.size());
|
||||
ExpectedPaging expectedPaging = RestApiUtil.parsePaging(response.getJsonResponse());
|
||||
@@ -164,7 +164,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
// SkipCount=2,MaxItems=3
|
||||
paging = getPaging(2, 3);
|
||||
// List all available renditions
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, 200);
|
||||
renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertEquals(3, renditions.size());
|
||||
expectedPaging = RestApiUtil.parsePaging(response.getJsonResponse());
|
||||
@@ -178,7 +178,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
// List all available renditions (includes those that have been created and those that are yet to be created)
|
||||
paging = getPaging(0, 50);
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, 200);
|
||||
renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertTrue(renditions.size() >= 5);
|
||||
docLib = getRendition(renditions, "doclib");
|
||||
@@ -192,13 +192,13 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
assertTrue(contentInfo.getSizeInBytes() > 0);
|
||||
|
||||
// List only the CREATED renditions
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertEquals("Should've only returned the 'doclib' rendition.", 1, renditions.size());
|
||||
|
||||
params.put("where", "(status='NOT_CREATED')");
|
||||
// List only the NOT_CREATED renditions
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertTrue(renditions.size() > 0);
|
||||
docLib = getRendition(renditions, "doclib");
|
||||
@@ -206,32 +206,32 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
// Test returned renditions are ordered (natural sort order)
|
||||
// List all renditions
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertTrue(Ordering.natural().isOrdered(renditions));
|
||||
// Try again to make sure the ordering wasn't coincidental
|
||||
response = getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
response = getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 200);
|
||||
renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
assertTrue(Ordering.natural().isOrdered(renditions));
|
||||
|
||||
// nodeId in the path parameter does not represent a file
|
||||
getAll(getRenditionsUrl(folder_Id), userOneN1.getId(), paging, params, 400);
|
||||
getAll(getNodeRenditionsUrl(folder_Id), userOneN1.getId(), paging, params, 400);
|
||||
|
||||
// nodeId in the path parameter does not exist
|
||||
getAll(getRenditionsUrl(UUID.randomUUID().toString()), userOneN1.getId(), paging, params, 404);
|
||||
getAll(getNodeRenditionsUrl(UUID.randomUUID().toString()), userOneN1.getId(), paging, params, 404);
|
||||
|
||||
// Create a node without any content
|
||||
String emptyContentNodeId = addToDocumentLibrary(userOneN1Site, "emptyDoc.txt", ContentModel.TYPE_CONTENT, userOneN1.getId());
|
||||
// The source node has no content
|
||||
getAll(getRenditionsUrl(emptyContentNodeId), userOneN1.getId(), paging, params, 400);
|
||||
getAll(getNodeRenditionsUrl(emptyContentNodeId), userOneN1.getId(), paging, params, 400);
|
||||
|
||||
// Invalid status value
|
||||
params.put("where", "(status='WRONG')");
|
||||
getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 400);
|
||||
getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 400);
|
||||
|
||||
// Invalid filter (only 'status' is supported)
|
||||
params.put("where", "(id='doclib')");
|
||||
getAll(getRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 400);
|
||||
getAll(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), paging, params, 400);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,7 +258,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
String contentNodeId = document.getId();
|
||||
|
||||
// Get rendition (not created yet) information for node
|
||||
response = getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib", 200);
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib", 200);
|
||||
Rendition rendition = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Rendition.class);
|
||||
assertNotNull(rendition);
|
||||
assertEquals(RenditionStatus.NOT_CREATED, rendition.getStatus());
|
||||
@@ -281,18 +281,18 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
assertTrue(contentInfo.getSizeInBytes() > 0);
|
||||
|
||||
// nodeId in the path parameter does not represent a file
|
||||
getSingle(getRenditionsUrl(folder_Id), userOneN1.getId(), "doclib", 400);
|
||||
getSingle(getNodeRenditionsUrl(folder_Id), userOneN1.getId(), "doclib", 400);
|
||||
|
||||
// nodeId in the path parameter does not exist
|
||||
getSingle(getRenditionsUrl(UUID.randomUUID().toString()), userOneN1.getId(), "doclib", 404);
|
||||
getSingle(getNodeRenditionsUrl(UUID.randomUUID().toString()), userOneN1.getId(), "doclib", 404);
|
||||
|
||||
// renditionId in the path parameter is not registered/available
|
||||
getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), ("renditionId" + System.currentTimeMillis()), 404);
|
||||
getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), ("renditionId" + System.currentTimeMillis()), 404);
|
||||
|
||||
// Create a node without any content
|
||||
String emptyContentNodeId = addToDocumentLibrary(userOneN1Site, "emptyDoc.txt", ContentModel.TYPE_CONTENT, userOneN1.getId());
|
||||
// The source node has no content
|
||||
getSingle(getRenditionsUrl(emptyContentNodeId), userOneN1.getId(), "doclib", 400);
|
||||
getSingle(getNodeRenditionsUrl(emptyContentNodeId), userOneN1.getId(), "doclib", 400);
|
||||
|
||||
// Create multipart request
|
||||
String jpgFileName = "quick.jpg";
|
||||
@@ -307,14 +307,14 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
String jpgImageNodeId = jpgImage.getId();
|
||||
|
||||
// List all available renditions (includes those that have been created and those that are yet to be created)
|
||||
response = getAll(getRenditionsUrl(jpgImageNodeId), userOneN1.getId(), getPaging(0, 50), 200);
|
||||
response = getAll(getNodeRenditionsUrl(jpgImageNodeId), userOneN1.getId(), getPaging(0, 50), 200);
|
||||
List<Rendition> renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
// Check there is no pdf rendition is available for the jpg file
|
||||
Rendition pdf = getRendition(renditions, "pdf");
|
||||
assertNull(pdf);
|
||||
|
||||
// The renditionId (pdf) is registered but it is not applicable for the node's mimeType
|
||||
getSingle(getRenditionsUrl(jpgImageNodeId), userOneN1.getId(), "pdf", 404);
|
||||
getSingle(getNodeRenditionsUrl(jpgImageNodeId), userOneN1.getId(), "pdf", 404);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +341,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
String contentNodeId = document.getId();
|
||||
|
||||
// Get rendition (not created yet) information for node
|
||||
response = getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), "imgpreview", 200);
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), "imgpreview", 200);
|
||||
Rendition rendition = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Rendition.class);
|
||||
assertNotNull(rendition);
|
||||
assertEquals(RenditionStatus.NOT_CREATED, rendition.getStatus());
|
||||
@@ -359,7 +359,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
// -ve Tests
|
||||
// The rendition requested already exists
|
||||
response = post(getRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId("imgpreview")), 409);
|
||||
response = post(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId("imgpreview")), 409);
|
||||
ExpectedErrorResponse errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse());
|
||||
assertNotNull(errorResponse);
|
||||
assertNotNull(errorResponse.getErrorKey());
|
||||
@@ -371,10 +371,10 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
// Create 'doclib' rendition request
|
||||
Rendition renditionRequest = new Rendition().setId("doclib");
|
||||
// nodeId in the path parameter does not represent a file
|
||||
post(getRenditionsUrl(folder_Id), userOneN1.getId(), toJsonAsString(renditionRequest), 400);
|
||||
post(getNodeRenditionsUrl(folder_Id), userOneN1.getId(), toJsonAsString(renditionRequest), 400);
|
||||
|
||||
// nodeId in the path parameter does not exist
|
||||
response = post(getRenditionsUrl(UUID.randomUUID().toString()), userOneN1.getId(), toJsonAsString(renditionRequest), 404);
|
||||
response = post(getNodeRenditionsUrl(UUID.randomUUID().toString()), userOneN1.getId(), toJsonAsString(renditionRequest), 404);
|
||||
// EntityNotFoundException
|
||||
errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse());
|
||||
assertNotNull(errorResponse);
|
||||
@@ -386,18 +386,18 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
// renditionId is not registered
|
||||
final String randomRenditionId = "renditionId" + System.currentTimeMillis();
|
||||
post(getRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId(randomRenditionId)), 404);
|
||||
post(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId(randomRenditionId)), 404);
|
||||
|
||||
// renditionId is null
|
||||
post(getRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId(null)), 400);
|
||||
post(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId(null)), 400);
|
||||
|
||||
// renditionId is empty
|
||||
post(getRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId("")), 400);
|
||||
post(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId("")), 400);
|
||||
|
||||
// Create a node without any content
|
||||
String emptyContentNodeId = addToDocumentLibrary(userOneN1Site, "emptyDoc.txt", ContentModel.TYPE_CONTENT, userOneN1.getId());
|
||||
// The source node has no content
|
||||
post(getRenditionsUrl(emptyContentNodeId), userOneN1.getId(), toJsonAsString(renditionRequest), 400);
|
||||
post(getNodeRenditionsUrl(emptyContentNodeId), userOneN1.getId(), toJsonAsString(renditionRequest), 400);
|
||||
|
||||
String content = "The quick brown fox jumps over the lazy dog.";
|
||||
file = TempFileProvider.createTempFile(new ByteArrayInputStream(content.getBytes()), getClass().getSimpleName(), ".bin");
|
||||
@@ -407,7 +407,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
Document binaryDocument = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
|
||||
// No transformer is currently available for 'application/octet-stream'
|
||||
post(getRenditionsUrl(binaryDocument.getId()), userOneN1.getId(), toJsonAsString(renditionRequest), 400);
|
||||
post(getNodeRenditionsUrl(binaryDocument.getId()), userOneN1.getId(), toJsonAsString(renditionRequest), 400);
|
||||
|
||||
ThumbnailService thumbnailService = applicationContext.getBean("thumbnailService", ThumbnailService.class);
|
||||
// Disable thumbnail generation
|
||||
@@ -423,7 +423,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
response = post("nodes/" + folder_Id + "/children", userOneN1.getId(), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||
Document txtDocument = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
// Thumbnail generation has been disabled
|
||||
response = post(getRenditionsUrl(txtDocument.getId()), userOneN1.getId(), toJsonAsString(renditionRequest), 501);
|
||||
response = post(getNodeRenditionsUrl(txtDocument.getId()), userOneN1.getId(), toJsonAsString(renditionRequest), 501);
|
||||
errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse());
|
||||
assertNotNull(errorResponse);
|
||||
assertNotNull(errorResponse.getErrorKey());
|
||||
@@ -463,7 +463,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
String contentNodeId = document.getId();
|
||||
|
||||
// Get rendition (not created yet) information for node
|
||||
response = getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib", 200);
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib", 200);
|
||||
Rendition rendition = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Rendition.class);
|
||||
assertNotNull(rendition);
|
||||
assertEquals(RenditionStatus.NOT_CREATED, rendition.getStatus());
|
||||
@@ -471,7 +471,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
// Download placeholder - by default with Content-Disposition header
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("placeholder", "true");
|
||||
response = getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), ("doclib/content"), params, 200);
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), ("doclib/content"), params, 200);
|
||||
assertNotNull(response.getResponseAsBytes());
|
||||
Map<String, String> responseHeaders = response.getHeaders();
|
||||
assertNotNull(responseHeaders);
|
||||
@@ -481,10 +481,12 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
String contentType = responseHeaders.get("Content-Type");
|
||||
assertNotNull(contentType);
|
||||
assertTrue(contentType.startsWith(MimetypeMap.MIMETYPE_IMAGE_PNG));
|
||||
assertNotNull(response.getHeaders().get("Last-Modified"));
|
||||
assertNotNull(response.getHeaders().get("Expires"));
|
||||
|
||||
// Download placeholder - without Content-Disposition header (attachment=false)
|
||||
params.put("attachment", "false");
|
||||
response = getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), ("doclib/content"), params, 200);
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), ("doclib/content"), params, 200);
|
||||
assertNotNull(response.getResponseAsBytes());
|
||||
responseHeaders = response.getHeaders();
|
||||
assertNotNull(responseHeaders);
|
||||
@@ -492,6 +494,8 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
contentType = responseHeaders.get("Content-Type");
|
||||
assertNotNull(contentType);
|
||||
assertTrue(contentType.startsWith(MimetypeMap.MIMETYPE_IMAGE_PNG));
|
||||
assertNotNull(response.getHeaders().get("Last-Modified"));
|
||||
assertNotNull(response.getHeaders().get("Expires"));
|
||||
|
||||
// Create and get 'doclib' rendition
|
||||
rendition = createAndGetRendition(userOneN1.getId(), contentNodeId, "doclib");
|
||||
@@ -499,7 +503,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
assertEquals(RenditionStatus.CREATED, rendition.getStatus());
|
||||
|
||||
// Download rendition - by default with Content-Disposition header
|
||||
response = getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", 200);
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", 200);
|
||||
assertNotNull(response.getResponseAsBytes());
|
||||
responseHeaders = response.getHeaders();
|
||||
assertNotNull(responseHeaders);
|
||||
@@ -509,10 +513,12 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
contentType = responseHeaders.get("Content-Type");
|
||||
assertNotNull(contentType);
|
||||
assertTrue(contentType.startsWith(MimetypeMap.MIMETYPE_IMAGE_PNG));
|
||||
assertNotNull(response.getHeaders().get("Last-Modified"));
|
||||
assertNotNull(response.getHeaders().get("Expires"));
|
||||
|
||||
// Download rendition - without Content-Disposition header (attachment=false)
|
||||
params = Collections.singletonMap("attachment", "false");
|
||||
response = getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", params, 200);
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", params, 200);
|
||||
assertNotNull(response.getResponseAsBytes());
|
||||
responseHeaders = response.getHeaders();
|
||||
assertNotNull(responseHeaders);
|
||||
@@ -520,10 +526,12 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
contentType = responseHeaders.get("Content-Type");
|
||||
assertNotNull(contentType);
|
||||
assertTrue(contentType.startsWith(MimetypeMap.MIMETYPE_IMAGE_PNG));
|
||||
assertNotNull(response.getHeaders().get("Last-Modified"));
|
||||
assertNotNull(response.getHeaders().get("Expires"));
|
||||
|
||||
// Download rendition - with Content-Disposition header (attachment=true) same as default
|
||||
params = Collections.singletonMap("attachment", "true");
|
||||
response = getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", params, 200);
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", params, 200);
|
||||
assertNotNull(response.getResponseAsBytes());
|
||||
responseHeaders = response.getHeaders();
|
||||
assertNotNull(responseHeaders);
|
||||
@@ -533,16 +541,18 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
contentType = responseHeaders.get("Content-Type");
|
||||
assertNotNull(contentType);
|
||||
assertTrue(contentType.startsWith(MimetypeMap.MIMETYPE_IMAGE_PNG));
|
||||
assertNotNull(response.getHeaders().get("Last-Modified"));
|
||||
assertNotNull(response.getHeaders().get("Expires"));
|
||||
|
||||
//-ve tests
|
||||
// nodeId in the path parameter does not represent a file
|
||||
getSingle(getRenditionsUrl(folder_Id), userOneN1.getId(), "doclib/content", 400);
|
||||
getSingle(getNodeRenditionsUrl(folder_Id), userOneN1.getId(), "doclib/content", 400);
|
||||
|
||||
// nodeId in the path parameter does not exist
|
||||
getSingle(getRenditionsUrl(UUID.randomUUID().toString()), userOneN1.getId(), "doclib/content", 404);
|
||||
getSingle(getNodeRenditionsUrl(UUID.randomUUID().toString()), userOneN1.getId(), "doclib/content", 404);
|
||||
|
||||
// renditionId in the path parameter is not registered/available
|
||||
getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), ("renditionId" + System.currentTimeMillis() + "/content"), 404);
|
||||
getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), ("renditionId" + System.currentTimeMillis() + "/content"), 404);
|
||||
|
||||
InputStream inputStream = new ByteArrayInputStream("The quick brown fox jumps over the lazy dog".getBytes());
|
||||
file = TempFileProvider.createTempFile(inputStream, "RenditionsTest-", ".abcdef");
|
||||
@@ -555,20 +565,20 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
contentNodeId = document.getId();
|
||||
|
||||
// The content of the rendition does not exist and the placeholder parameter is not present
|
||||
getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", 404);
|
||||
getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", 404);
|
||||
|
||||
// The content of the rendition does not exist and the placeholder parameter has a value of "false"
|
||||
params = Collections.singletonMap("placeholder", "false");
|
||||
getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", params, 404);
|
||||
getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), "doclib/content", params, 404);
|
||||
|
||||
// The rendition does not exist, a placeholder is not available and the placeholder parameter has a value of "true"
|
||||
params = Collections.singletonMap("placeholder", "true");
|
||||
getSingle(getRenditionsUrl(contentNodeId), userOneN1.getId(), ("renditionId" + System.currentTimeMillis() + "/content"), params, 404);
|
||||
getSingle(getNodeRenditionsUrl(contentNodeId), userOneN1.getId(), ("renditionId" + System.currentTimeMillis() + "/content"), params, 404);
|
||||
|
||||
// Create a node without any content
|
||||
String emptyContentNodeId = addToDocumentLibrary(userOneN1Site, "emptyDoc.txt", ContentModel.TYPE_CONTENT, userOneN1.getId());
|
||||
// The source node has no content
|
||||
getSingle(getRenditionsUrl(emptyContentNodeId), userOneN1.getId(), "doclib/content", params, 400);
|
||||
getSingle(getNodeRenditionsUrl(emptyContentNodeId), userOneN1.getId(), "doclib/content", params, 400);
|
||||
|
||||
//TODO add tests for 304 response
|
||||
}
|
||||
@@ -597,11 +607,6 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getRenditionsUrl(String nodeId)
|
||||
{
|
||||
return "nodes/" + nodeId + "/renditions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScope()
|
||||
{
|
||||
|
Reference in New Issue
Block a user