mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
[feature/MNT-24127-EndpointToCalculateFolderSize] Creating Integeration test cases
This commit is contained in:
@@ -2,6 +2,8 @@ package org.alfresco.rest.nodes;
|
|||||||
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
|
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
@@ -127,11 +129,11 @@ public class NodeSizeDetailsTests extends RestTest
|
|||||||
|
|
||||||
STEP("2. Creating a 200 nested folders in the folder-1");
|
STEP("2. Creating a 200 nested folders in the folder-1");
|
||||||
|
|
||||||
for (int i = 1; i <= 200; i++)
|
IntStream.rangeClosed(1, 5).forEach(i -> {
|
||||||
{
|
|
||||||
String folder0Name = "childFolder" + i + RandomStringUtils.randomAlphanumeric(2);
|
String folder0Name = "childFolder" + i + RandomStringUtils.randomAlphanumeric(2);
|
||||||
FolderModel folderModel = new FolderModel();
|
FolderModel folderModel = new FolderModel();
|
||||||
folderModel.setName(folder0Name);
|
folderModel.setName(folder0Name);
|
||||||
|
|
||||||
FolderModel childFolder = dataContent.usingUser(user1)
|
FolderModel childFolder = dataContent.usingUser(user1)
|
||||||
.usingSite(siteModel)
|
.usingSite(siteModel)
|
||||||
.usingResource(folder)
|
.usingResource(folder)
|
||||||
@@ -141,10 +143,12 @@ public class NodeSizeDetailsTests extends RestTest
|
|||||||
restClient.authenticateUser(user1)
|
restClient.authenticateUser(user1)
|
||||||
.configureRequestSpec()
|
.configureRequestSpec()
|
||||||
.addMultiPart("filedata", Utility.getResourceTestDataFile("sampleLargeContent.txt"));
|
.addMultiPart("filedata", Utility.getResourceTestDataFile("sampleLargeContent.txt"));
|
||||||
|
|
||||||
RestNodeModel newNode = restClient.authenticateUser(user1)
|
RestNodeModel newNode = restClient.authenticateUser(user1)
|
||||||
.withCoreAPI()
|
.withCoreAPI()
|
||||||
.usingNode(childFolder)
|
.usingNode(childFolder)
|
||||||
.createNode();
|
.createNode();
|
||||||
|
|
||||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||||
|
|
||||||
newNode.assertThat()
|
newNode.assertThat()
|
||||||
@@ -156,20 +160,19 @@ public class NodeSizeDetailsTests extends RestTest
|
|||||||
.and()
|
.and()
|
||||||
.field("content.mimeType")
|
.field("content.mimeType")
|
||||||
.is(FileType.TEXT_PLAIN.mimeType);
|
.is(FileType.TEXT_PLAIN.mimeType);
|
||||||
|
});
|
||||||
}
|
|
||||||
|
|
||||||
RestSizeDetailsModel restSizeDetailsModel = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).executeSizeDetails();
|
RestSizeDetailsModel restSizeDetailsModel = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).executeSizeDetails();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
|
restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
|
||||||
restSizeDetailsModel.assertThat().field("jobId").isNotEmpty();
|
restSizeDetailsModel.assertThat().field("jobId").isNotEmpty();
|
||||||
|
|
||||||
Thread.sleep(2000);
|
|
||||||
|
|
||||||
String jobId = restSizeDetailsModel.getJobId();
|
String jobId = restSizeDetailsModel.getJobId();
|
||||||
restSizeDetailsModel = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).getSizeDetails(jobId);
|
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
Utility.sleep(2000, 60000, () -> {
|
||||||
restSizeDetailsModel.assertThat().field("sizeInBytes").isNotEmpty();
|
RestSizeDetailsModel sizeDetailsModel = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).getSizeDetails(jobId);
|
||||||
restSizeDetailsModel.assertThat().field("sizeInBytes").isGreaterThan(0);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
|
sizeDetailsModel.assertThat().field("sizeInBytes").isNotEmpty();
|
||||||
|
sizeDetailsModel.assertThat().field("sizeInBytes").isGreaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user