mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
-add tests for the issue RM-4568
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
||||
|
||||
import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_NAME;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.HOLDS_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
||||
@@ -34,6 +37,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||
@@ -42,7 +47,11 @@ import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentContent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -241,4 +250,80 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
// and end with its extension
|
||||
assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf("."))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Bug (id = "RM-4568")
|
||||
/**
|
||||
* Given I want to create an electronic record
|
||||
* When I use the path relative to the filePlanComponentid
|
||||
* Then the containers in the relativePath that don't exist are created before creating the electronic record
|
||||
|
||||
*/
|
||||
public void createElectronicRecordWithRelativePath() throws Exception
|
||||
{
|
||||
//the containers specified on the RELATIVE_PATH parameter don't exist on server
|
||||
String RELATIVE_PATH = CATEGORY_NAME + "/"+ CATEGORY_NAME +"/"+ FOLDER_NAME;
|
||||
FilePlanComponent electronicRecord = FilePlanComponent.builder()
|
||||
.name(ELECTRONIC_RECORD_NAME)
|
||||
.nodeType(CONTENT_TYPE.toString())
|
||||
.content(FilePlanComponentContent.builder().mimeType("text/plain").build())
|
||||
.properties(FilePlanComponentProperties.builder().description("Description").build())
|
||||
.relativePath(RELATIVE_PATH)
|
||||
.build();
|
||||
|
||||
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||
FilePlanComponent recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord,
|
||||
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS);
|
||||
// verify the create request status code
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// get newly created electronic record and verify its properties
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().equals(FOLDER_NAME));
|
||||
//get newly created electronic record using the relativePath
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS,
|
||||
FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName())
|
||||
.getId().equals(recordCreated.getId()));
|
||||
|
||||
//the category specified via the RELATIVE_PATH exist, folder doesn't exist
|
||||
RELATIVE_PATH = CATEGORY_NAME + "/" + FOLDER_NAME;
|
||||
electronicRecord.setRelativePath(RELATIVE_PATH);
|
||||
recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS);
|
||||
// verify the create request status code
|
||||
assertStatusCode(CREATED);
|
||||
// get newly created electronic record and verify its properties
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME));
|
||||
//get newly created electronic record using the relativePath
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS,
|
||||
FilePlanComponentFields.RELATIVE_PATH+"="+RELATIVE_PATH+"/"+recordCreated.getName())
|
||||
.getId().equals(recordCreated.getId()));
|
||||
|
||||
//the containers from the RELATIVE PATH exists
|
||||
electronicRecord.setName(ELECTRONIC_RECORD_NAME + getRandomAlphanumeric());
|
||||
recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord,
|
||||
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME),
|
||||
FILE_PLAN_ALIAS);
|
||||
// verify the create request status code
|
||||
assertStatusCode(CREATED);
|
||||
// get newly created electronic record and verify its properties
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME));
|
||||
//get newly created electronic record using the relativePath
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName())
|
||||
.getId().equals(recordCreated.getId()));
|
||||
|
||||
String categoryId =filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "="+CATEGORY_NAME)
|
||||
.getId();
|
||||
RELATIVE_PATH="Category two/"+FOLDER_NAME;
|
||||
electronicRecord.setRelativePath(RELATIVE_PATH);
|
||||
recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord,
|
||||
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME),categoryId);
|
||||
// verify the create request status code
|
||||
assertStatusCode(CREATED);
|
||||
// get newly created electronic record and verify its properties
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME));
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user