mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix/apps 2894 node size details automation test (#3032)
* 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. --------- Co-authored-by: kshah <kavit.shah@hyland.com> Co-authored-by: mohit-singh4 <mohit.singh@contractors.hyland.com>
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.awaitility.Durations;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.model.RestSizeDetailsModel;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.*;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
|
||||
@@ -20,6 +29,7 @@ public class NodeSizeDetailsTests extends RestTest
|
||||
private UserModel user1;
|
||||
private SiteModel siteModel;
|
||||
private FolderModel folder;
|
||||
private String jobId;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation()
|
||||
@@ -30,7 +40,163 @@ public class NodeSizeDetailsTests extends RestTest
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* calculateNodeSizeForSingleFile testcase
|
||||
*/
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.NODES}, executionType = ExecutionType.SANITY)
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void calculateNodeSizeForSingleFile() throws Exception
|
||||
{
|
||||
|
||||
STEP("1. Create a folder in the test site.");
|
||||
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();
|
||||
|
||||
STEP("3. Wait for 30 seconds so that the content is indexed in Search Service.");
|
||||
Utility.waitToLoopTime(30);
|
||||
|
||||
RestSizeDetailsModel restSizeDetailsModel = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).executeSizeDetails();
|
||||
restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
|
||||
restSizeDetailsModel.assertThat().field("jobId").isNotEmpty();
|
||||
|
||||
jobId = restSizeDetailsModel.getJobId();
|
||||
|
||||
STEP("4. Wait for 10 seconds for the processing to complete.");
|
||||
Awaitility
|
||||
.await()
|
||||
.atMost(Duration.ofSeconds(10))
|
||||
.pollInterval(Durations.ONE_SECOND)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
RestSizeDetailsModel sizeDetailsModel = restClient.authenticateUser(user1)
|
||||
.withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.getSizeDetails(jobId);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
sizeDetailsModel.assertThat()
|
||||
.field("sizeInBytes")
|
||||
.isNotEmpty();
|
||||
Assert.assertEquals(sizeDetailsModel.getSizeInBytes(), fileSize,
|
||||
"Value of sizeInBytes " + sizeDetailsModel.getSizeInBytes()
|
||||
+ " is not equal to " + fileSize);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* checkJobIdPresentInCache testcase
|
||||
*/
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.NODES}, executionType = ExecutionType.SANITY)
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void checkJobIdPresentInCache() throws Exception
|
||||
{
|
||||
STEP("1. Verifying that same JobId is coming or not");
|
||||
RestSizeDetailsModel restSizeDetailsModel = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).executeSizeDetails();
|
||||
restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
|
||||
restSizeDetailsModel.assertThat().field("jobId").isNotEmpty();
|
||||
Assert.assertEquals(restSizeDetailsModel.getJobId(), jobId, "jobId should be present in cache, actual :" + restSizeDetailsModel.getJobId() + " expected: " + jobId);
|
||||
}
|
||||
|
||||
/**
|
||||
* checkSizeDetailsWithInvalidJobId testcase
|
||||
*/
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.NODES}, executionType = ExecutionType.SANITY)
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void checkSizeDetailsWithInvalidJobId() throws Exception
|
||||
{
|
||||
|
||||
STEP("1. Create a folder in the test site.");
|
||||
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);
|
||||
|
||||
STEP("3. Wait for 30 seconds so that the content is indexed in Search Service.");
|
||||
Utility.waitToLoopTime(30);
|
||||
|
||||
RestSizeDetailsModel restSizeDetailsModel = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).executeSizeDetails();
|
||||
restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
|
||||
restSizeDetailsModel.assertThat().field("jobId").isNotEmpty();
|
||||
jobId = restSizeDetailsModel.getJobId();
|
||||
|
||||
STEP("4. Adding random content to jobId ");
|
||||
jobId += RandomStringUtils.randomAlphanumeric(2);
|
||||
|
||||
STEP("5. Wait for 10 seconds for the processing to complete.");
|
||||
Awaitility
|
||||
.await()
|
||||
.atMost(Duration.ofSeconds(10))
|
||||
.pollInterval(Durations.ONE_SECOND)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
restClient.authenticateUser(user1)
|
||||
.withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.getSizeDetails(jobId);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* checkSizeDetailsWithoutExecuteSizeDetails testcase
|
||||
*/
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.NODES}, executionType = ExecutionType.SANITY)
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void checkSizeDetailsWithoutExecuteSizeDetails() throws Exception
|
||||
{
|
||||
|
||||
STEP("1. Create a folder in the test site.");
|
||||
folder = dataContent.usingUser(user1).usingSite(siteModel).createFolder(FolderModel.getRandomFolderModel());
|
||||
|
||||
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);
|
||||
|
||||
STEP("3. Wait for 30 seconds so that the content is indexed in Search Service.");
|
||||
Awaitility
|
||||
.await()
|
||||
.atMost(Duration.ofSeconds(30))
|
||||
.pollInterval(Durations.ONE_SECOND)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
RestSizeDetailsModel sizeDetailsModel = restClient.authenticateUser(user1)
|
||||
.withCoreAPI()
|
||||
.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);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Unauthenticated user not able to execute POST /nodes/{nodeId}/size-details: 401 STATUS CODE
|
||||
*/
|
||||
|
||||
@@ -57,7 +223,6 @@ public class NodeSizeDetailsTests extends RestTest
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Value of nodeId is invalid: 422 STATUS CODE
|
||||
*/
|
||||
|
||||
@@ -69,4 +234,168 @@ public class NodeSizeDetailsTests extends RestTest
|
||||
restClient.authenticateUser(user1).withCoreAPI().usingNode(document).executeSizeDetails();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* calculateNodeSizeForMultipleFiles testCase
|
||||
*/
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.NODES}, executionType = ExecutionType.SANITY)
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void calculateNodeSizeForMultipleFiles() throws InterruptedException
|
||||
{
|
||||
STEP("1. Create a parent folder in the test site.");
|
||||
FolderModel folder = dataContent.usingUser(user1).usingSite(siteModel).createFolder(FolderModel.getRandomFolderModel());
|
||||
|
||||
STEP("2. Creating a 5 nested folders in the folder-1");
|
||||
AtomicLong fileSize = new AtomicLong(0);
|
||||
|
||||
IntStream.rangeClosed(1, 5).forEach(i -> {
|
||||
String folder0Name = "childFolder" + i + RandomStringUtils.randomAlphanumeric(2);
|
||||
FolderModel folderModel = new FolderModel();
|
||||
folderModel.setName(folder0Name);
|
||||
|
||||
FolderModel childFolder = dataContent.usingUser(user1)
|
||||
.usingSite(siteModel)
|
||||
.usingResource(folder)
|
||||
.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);
|
||||
});
|
||||
|
||||
STEP("4. Wait for 30 seconds so that the content is indexed in Search Service.");
|
||||
Utility.waitToLoopTime(30);
|
||||
|
||||
RestSizeDetailsModel restSizeDetailsModel = restClient
|
||||
.authenticateUser(user1)
|
||||
.withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.executeSizeDetails();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
|
||||
restSizeDetailsModel.assertThat().field("jobId").isNotEmpty();
|
||||
|
||||
String jobId = restSizeDetailsModel.getJobId();
|
||||
|
||||
STEP("5. Wait for 5 seconds for the processing to complete.");
|
||||
Awaitility
|
||||
.await()
|
||||
.atMost(Duration.ofSeconds(5))
|
||||
.pollInterval(Durations.ONE_SECOND)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
RestSizeDetailsModel sizeDetailsModel = restClient.authenticateUser(user1)
|
||||
.withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.getSizeDetails(jobId);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
sizeDetailsModel.assertThat()
|
||||
.field("sizeInBytes")
|
||||
.isNotEmpty();
|
||||
Assert.assertEquals(sizeDetailsModel.getSizeInBytes(), fileSize.get(),
|
||||
"Value of sizeInBytes " + sizeDetailsModel.getSizeInBytes()
|
||||
+ " is not equal to " + fileSize.get());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* checkNumberOfFiles testCase
|
||||
*/
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.NODES}, executionType = ExecutionType.SANITY)
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void checkNumberOfFiles() throws InterruptedException
|
||||
{
|
||||
STEP("1. Create a parent folder in the test site.");
|
||||
FolderModel folder = dataContent.usingUser(user1).usingSite(siteModel).createFolder(FolderModel.getRandomFolderModel());
|
||||
|
||||
STEP("2. Creating a 10 nested folders in the folder-1");
|
||||
|
||||
IntStream.rangeClosed(1, 10).forEach(i -> {
|
||||
String folder0Name = "childFolder" + i + RandomStringUtils.randomAlphanumeric(2);
|
||||
FolderModel folderModel = new FolderModel();
|
||||
folderModel.setName(folder0Name);
|
||||
|
||||
FolderModel childFolder = dataContent.usingUser(user1)
|
||||
.usingSite(siteModel)
|
||||
.usingResource(folder)
|
||||
.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);
|
||||
});
|
||||
|
||||
STEP("4. Wait for 30 seconds so that the content is indexed in Search Service.");
|
||||
Utility.waitToLoopTime(30);
|
||||
|
||||
RestSizeDetailsModel restSizeDetailsModel = restClient
|
||||
.authenticateUser(user1)
|
||||
.withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.executeSizeDetails();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
|
||||
restSizeDetailsModel.assertThat().field("jobId").isNotEmpty();
|
||||
|
||||
String jobId = restSizeDetailsModel.getJobId();
|
||||
|
||||
STEP("5. Wait for 10 seconds for the processing to complete.");
|
||||
Awaitility
|
||||
.await()
|
||||
.atMost(Duration.ofSeconds(10))
|
||||
.pollInterval(Durations.ONE_SECOND)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
RestSizeDetailsModel sizeDetailsModel = restClient.authenticateUser(user1)
|
||||
.withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.getSizeDetails(jobId);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
sizeDetailsModel.assertThat().field("numberOfFiles").isNotEmpty();
|
||||
Assert.assertEquals(sizeDetailsModel.getNumberOfFiles(), 10, "Value of NumberOfFiles " + sizeDetailsModel.getNumberOfFiles() + " is not equal to " + 10);
|
||||
});
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanup() throws Exception
|
||||
{
|
||||
dataSite.usingUser(user1).deleteSite(siteModel);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user