[MNT-24127] Added Endpoint to Calculate Size of the folder with Integration Test Cases [ags][tas]

This commit is contained in:
mohit-singh4
2024-06-27 19:05:16 +05:30
parent 5e024c95c2
commit 6aaa24d9d6

View File

@@ -43,6 +43,7 @@ import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.Test; import org.junit.Test;
@@ -81,7 +82,7 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest
private String folderName; private String folderName;
private String folderId; private static String folderId;
/** /**
* The logger * The logger
@@ -147,12 +148,12 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest
public void testPerformance() throws Exception public void testPerformance() throws Exception
{ {
setRequestContext(user1); setRequestContext(user1);
Node n; Node parentNodes;
// Logging initial time. // Logging initial time.
LocalDateTime eventTimestamp = LocalDateTime.now(); LocalDateTime eventTimestamp = LocalDateTime.now();
String formattedTimestamp = eventTimestamp.format(DateTimeFormatter.ofPattern("yyyy:MM:dd HH:mm:ss")); String formattedTimestamp = eventTimestamp.format(DateTimeFormatter.ofPattern("yyyy:MM:dd HH:mm:ss"));
System.out.println(" ********** In NodeFolderSizeApiTest:testPerformance Initial Time :"+formattedTimestamp); LOG.info(" ********** In NodeFolderSizeApiTest:testPerformance Initial Time :{}", formattedTimestamp);
String siteTitle = "RandomSite" + System.currentTimeMillis(); String siteTitle = "RandomSite" + System.currentTimeMillis();
userOneN1Site = createSite("RN"+RUNID, siteTitle, siteTitle, SiteVisibility.PRIVATE, 201); userOneN1Site = createSite("RN"+RUNID, siteTitle, siteTitle, SiteVisibility.PRIVATE, 201);
@@ -165,28 +166,28 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest
for(int i =0;i<300;i++) for(int i =0;i<300;i++)
{ {
n = new Node(); parentNodes = new Node();
n.setName("c1" + RUNID); parentNodes.setName("c1" + RUNID);
n.setNodeType(TYPE_CM_FOLDER); parentNodes.setNodeType(TYPE_CM_FOLDER);
QName assocChildQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(n.getName())); QName assocChildQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(parentNodes.getName()));
if(i%7==0) if(i%7==0)
{ {
for(int j =0 ; j<=5; j++) for(int j =0 ; j<=5; j++)
{ {
n = new Node(); Node childNodes = new Node();
n.setName("c2" + RUNID); childNodes.setName("c2" + RUNID);
n.setNodeType(TYPE_CM_CONTENT); childNodes.setNodeType(TYPE_CM_CONTENT);
ContentData contentData = new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 10L, null); ContentData contentData = new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 10L, null);
String mimeType = contentData.getMimetype(); String mimeType = contentData.getMimetype();
String mimeTypeName = mimeTypeService.getDisplaysByMimetype().get(mimeType); String mimeTypeName = mimeTypeService.getDisplaysByMimetype().get(mimeType);
ContentInfo contentInfo = new ContentInfo(mimeType, mimeTypeName, contentData.getSize(),contentData.getEncoding()); ContentInfo contentInfo = new ContentInfo(mimeType, mimeTypeName, contentData.getSize(),contentData.getEncoding());
n.setContent(contentInfo); childNodes.setContent(contentInfo);
QName assocChildQNameInternal = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(n.getName())); QName assocChildQNameInternal = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(childNodes.getName()));
nodeService.addChild(n.getNodeRef(), new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, n.getName()), qName, assocChildQNameInternal); nodeService.addChild(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,parentNodes.getNodeId()), new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, childNodes.getName()), qName, assocChildQNameInternal);
} }
} }
nodeService.addChild(nodeRef, new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, n.getName()), qName, assocChildQName); nodeService.addChild(nodeRef, new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, parentNodes.getName()), qName, assocChildQName);
} }
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("nodeId",folderId); params.put("nodeId",folderId);
@@ -199,7 +200,7 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest
{ {
eventTimestamp = LocalDateTime.now(); eventTimestamp = LocalDateTime.now();
formattedTimestamp = eventTimestamp.format(DateTimeFormatter.ofPattern("yyyy:MM:dd HH:mm:ss")); formattedTimestamp = eventTimestamp.format(DateTimeFormatter.ofPattern("yyyy:MM:dd HH:mm:ss"));
System.out.println(" ********** In NodeFolderSizeApiTest:testPerformance Completed Time :"+formattedTimestamp); LOG.info(" ********** In NodeFolderSizeApiTest:testPerformance Completed Time :{}", formattedTimestamp);
} }
assertNotNull(contentNodeId); assertNotNull(contentNodeId);
} }