Fix/apps 2894 node size details automation sample test file (#3036)

* Adding the test case for calculating the NodeSize.

* Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationTest] Adding the test case for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationSampleTestFile] Updating sample testfile which being used for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationSampleTestFile] Updating sample testfile which being used for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationSampleTestFile] Updating sample testfile which being used for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationSampleTestFile] Updating sample testfile which being used for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationSampleTestFile] Updating sample testfile which being used for calculating the NodeSize.

* [fix/APPS-2894_NodeSizeDetails_AutomationSampleTestFile] Updating sample testfile which being used for calculating the NodeSize.

---------

Co-authored-by: kshah <kavit.shah@hyland.com>
Co-authored-by: mohit-singh4 <mohit.singh@contractors.hyland.com>
This commit is contained in:
mohit-singh4
2024-11-14 18:53:27 +05:30
committed by GitHub
parent 3de74456ae
commit 867af27a96

View File

@@ -1,7 +1,11 @@
package org.alfresco.rest.nodes;
import static java.util.Objects.requireNonNull;
import static org.alfresco.utility.report.log.Step.STEP;
import java.io.IOException;
import java.io.InputStream;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.IntStream;
@@ -17,7 +21,6 @@ import org.testng.annotations.Test;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestNodeModel;
import org.alfresco.rest.model.RestSizeDetailsModel;
import org.alfresco.utility.Utility;
import org.alfresco.utility.model.*;
@@ -30,13 +33,19 @@ public class NodeSizeDetailsTests extends RestTest
private SiteModel siteModel;
private FolderModel folder;
private String jobId;
private FileModel sampleFileToCreate;
private long sampleFileSize;
@BeforeClass(alwaysRun = true)
public void dataPreparation()
public void dataPreparation() throws IOException
{
user1 = dataUser.createRandomTestUser("User-1");
siteModel = dataSite.usingUser(user1).createPublicRandomSite();
folder = dataContent.usingUser(user1).usingSite(siteModel).createFolder(FolderModel.getRandomFolderModel());
String fileName = "sampleLargeContent.txt";
final byte[] sampleFileContent = getSampleFileContent(fileName);
sampleFileSize = sampleFileContent.length;
sampleFileToCreate = new FileModel(fileName, FileType.TEXT_PLAIN, new String(sampleFileContent));
}
/**
@@ -52,15 +61,10 @@ public class NodeSizeDetailsTests extends RestTest
folder = dataContent.usingUser(user1).usingSite(siteModel).createFolder(FolderModel.getRandomFolderModel());
STEP("2. Upload a text document to the folder.");
long fileSize;
restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("sampleLargeContent.txt"));
RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
fileNode.assertThat().field("id").isNotNull()
.and().field("name").is("sampleLargeContent.txt")
.and().field("content.mimeType").is(FileType.TEXT_PLAIN.mimeType);
fileSize = Utility.getResourceTestDataFile("sampleLargeContent.txt").length();
dataContent.usingUser(user1)
.usingSite(siteModel)
.usingResource(folder)
.createContent(sampleFileToCreate);
STEP("3. Wait for 30 seconds so that the content is indexed in Search Service.");
Utility.waitToLoopTime(30);
@@ -71,10 +75,10 @@ public class NodeSizeDetailsTests extends RestTest
jobId = restSizeDetailsModel.getJobId();
STEP("4. Wait for 10 seconds for the processing to complete.");
STEP("4. Wait for 5 seconds for the processing to complete.");
Awaitility
.await()
.atMost(Duration.ofSeconds(10))
.atMost(Duration.ofSeconds(5))
.pollInterval(Durations.ONE_SECOND)
.ignoreExceptions()
.untilAsserted(() -> {
@@ -86,9 +90,9 @@ public class NodeSizeDetailsTests extends RestTest
sizeDetailsModel.assertThat()
.field("sizeInBytes")
.isNotEmpty();
Assert.assertEquals(sizeDetailsModel.getSizeInBytes(), fileSize,
Assert.assertEquals(sizeDetailsModel.getSizeInBytes(), sampleFileSize,
"Value of sizeInBytes " + sizeDetailsModel.getSizeInBytes()
+ " is not equal to " + fileSize);
+ " is not equal to " + sampleFileSize);
});
}
@@ -120,13 +124,10 @@ public class NodeSizeDetailsTests extends RestTest
folder = dataContent.usingUser(user1).usingSite(siteModel).createFolder(FolderModel.getRandomFolderModel());
STEP("2. Upload a text document to the folder.");
restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("sampleLargeContent.txt"));
RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
fileNode.assertThat().field("id").isNotNull()
.and().field("name").is("sampleLargeContent.txt")
.and().field("content.mimeType").is(FileType.TEXT_PLAIN.mimeType);
dataContent.usingUser(user1)
.usingSite(siteModel)
.usingResource(folder)
.createContent(sampleFileToCreate);
STEP("3. Wait for 30 seconds so that the content is indexed in Search Service.");
Utility.waitToLoopTime(30);
@@ -170,12 +171,11 @@ public class NodeSizeDetailsTests extends RestTest
STEP("2. Upload a text document to the folder.");
String status = "NOT_INITIATED";
restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("sampleLargeContent.txt"));
RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
fileNode.assertThat().field("id").isNotNull()
.and().field("name").is("sampleLargeContent.txt")
.and().field("content.mimeType").is(FileType.TEXT_PLAIN.mimeType);
FileModel fileModel = dataContent.usingUser(user1)
.usingSite(siteModel)
.usingResource(folder)
.createContent(sampleFileToCreate);
Assert.assertNotNull(fileModel, "fileModel should not be null");
STEP("3. Wait for 30 seconds so that the content is indexed in Search Service.");
Awaitility
@@ -189,7 +189,6 @@ public class NodeSizeDetailsTests extends RestTest
.usingNode(folder)
.getSizeDetails(jobId);
restClient.assertStatusCodeIs(HttpStatus.OK);
restClient.assertStatusCodeIs(HttpStatus.OK);
sizeDetailsModel.assertThat().field("status").isNotEmpty();
Assert.assertEquals(sizeDetailsModel.getStatus().toString(), status, "Value of status should be same, actual :" + sizeDetailsModel.getStatus().toString() + " expected: " + status);
});
@@ -260,26 +259,11 @@ public class NodeSizeDetailsTests extends RestTest
.createFolder(folderModel);
STEP("3. Upload a text document to the childFolders.");
restClient.authenticateUser(user1)
.configureRequestSpec()
.addMultiPart("filedata", Utility.getResourceTestDataFile("sampleLargeContent.txt"));
fileSize.addAndGet(Utility.getResourceTestDataFile("sampleLargeContent.txt").length());
RestNodeModel newNode = restClient.authenticateUser(user1)
.withCoreAPI()
.usingNode(childFolder)
.createNode();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
newNode.assertThat()
.field("id")
.isNotNull()
.and()
.field("name")
.is("sampleLargeContent.txt")
.and()
.field("content.mimeType")
.is(FileType.TEXT_PLAIN.mimeType);
dataContent.usingUser(user1)
.usingSite(siteModel)
.usingResource(childFolder)
.createContent(sampleFileToCreate);
fileSize.addAndGet(sampleFileSize);
});
STEP("4. Wait for 30 seconds so that the content is indexed in Search Service.");
@@ -341,25 +325,10 @@ public class NodeSizeDetailsTests extends RestTest
.createFolder(folderModel);
STEP("3. Upload a text document to the childFolders.");
restClient.authenticateUser(user1)
.configureRequestSpec()
.addMultiPart("filedata", Utility.getResourceTestDataFile("sampleLargeContent.txt"));
RestNodeModel newNode = restClient.authenticateUser(user1)
.withCoreAPI()
.usingNode(childFolder)
.createNode();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
newNode.assertThat()
.field("id")
.isNotNull()
.and()
.field("name")
.is("sampleLargeContent.txt")
.and()
.field("content.mimeType")
.is(FileType.TEXT_PLAIN.mimeType);
dataContent.usingUser(user1)
.usingSite(siteModel)
.usingResource(childFolder)
.createContent(sampleFileToCreate);
});
STEP("4. Wait for 30 seconds so that the content is indexed in Search Service.");
@@ -393,6 +362,16 @@ public class NodeSizeDetailsTests extends RestTest
});
}
private byte[] getSampleFileContent(String fileName) throws IOException
{
final String fileClasspathLocation = "/shared-resources/testdata/" + fileName;
try (InputStream fileStream = getClass().getResourceAsStream(fileClasspathLocation))
{
requireNonNull(fileStream, "Couldn't locate `" + fileClasspathLocation + "`");
return fileStream.readAllBytes();
}
}
@AfterClass(alwaysRun = true)
public void cleanup() throws Exception
{