From 50cd40a1ba6ad8ce9392bcc72860e6e3085c9656 Mon Sep 17 00:00:00 2001 From: Mohit Singh Date: Sat, 3 Aug 2024 15:13:05 +0530 Subject: [PATCH] [feature/MNT-24127-EndpointToCalculateFolderSize] Added Endpoint to calculate folder size --- .../rest/api/tests/NodeFolderSizeApiTest.java | 47 ++++--------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/remote-api/src/test/java/org/alfresco/rest/api/tests/NodeFolderSizeApiTest.java b/remote-api/src/test/java/org/alfresco/rest/api/tests/NodeFolderSizeApiTest.java index 75cbfd9c0f..901fccd053 100644 --- a/remote-api/src/test/java/org/alfresco/rest/api/tests/NodeFolderSizeApiTest.java +++ b/remote-api/src/test/java/org/alfresco/rest/api/tests/NodeFolderSizeApiTest.java @@ -113,55 +113,24 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest params.put("maxItems", "100"); // Perform POST request - HttpResponse response = post(getCalculateFolderSizeUrl(folderId), toJsonAsStringNonNull(params), 202); - simpleCache = (SimpleCache) this.applicationContext.getBean("folderSizeSharedCache"); - Object resultAction = simpleCache.get(folderId); - assertNotNull("simpleCache response should not be null", resultAction); + HttpResponse postResponse = post(getCalculateFolderSizeUrl(folderId), toJsonAsStringNonNull(params), 202); // Validate response and parsed document - assertNotNull("Response should not be null", response); + assertNotNull("Response should not be null", postResponse); - String jsonResponse = String.valueOf(response.getJsonResponse()); + String jsonResponse = String.valueOf(postResponse.getJsonResponse()); assertNotNull("JSON response should not be null", jsonResponse); // Parse JSON response - Object document = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Object.class); + Object document = RestApiUtil.parseRestApiEntry(postResponse.getJsonResponse(), Object.class); assertNotNull("Parsed document should not be null", document); - // Convert document to string and validate executionId - String executionId = document.toString(); - assertNotNull("executionId should not be null", executionId); - } + HttpResponse getResponse = getSingle(NodesEntityResource.class, folderId + "/get-folder-size", null, 200); - /** - * Test case for GET/get-folder-size, to retrieve FolderSize. - *

GET:

- * {@literal :/alfresco/api/-default-/public/alfresco/versions/1/nodes//get-folder-size} - */ - @Test - public void testBGetCalculateFolderSize() throws Exception - { - setRequestContext(user1); + String getJsonResponse = String.valueOf(getResponse.getJsonResponse()); + assertNotNull("JSON response should not be null", getJsonResponse); - // Check if response and JSON parsing were successful - simpleCache = (SimpleCache) this.applicationContext.getBean("folderSizeSharedCache"); - Object resultAction = simpleCache.get(folderId); - assertNotNull("simpleCache response should not be null", resultAction); - - HttpResponse response = getSingle(NodesEntityResource.class, folderId + "/get-folder-size", null, 200); - - String jsonResponse = String.valueOf(response.getJsonResponse()); - assertNotNull("JSON response should not be null", jsonResponse); - - assertTrue("We are not getting correct response "+jsonResponse,jsonResponse.contains("size") || jsonResponse.contains("status")); - - // Parse the JSON response. - Object document = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Object.class); - assertNotNull("Parsed document should not be null", document); - - // Convert document to string and verify contentNodeId. - String contentNodeId = document.toString(); - assertNotNull("Content node ID should not be null", contentNodeId); + assertTrue("We are not getting correct response "+getJsonResponse,getJsonResponse.contains("size") || getJsonResponse.contains("status")); } /**