mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge remote-tracking branch 'origin/master' into feature/RM-4615_TAS_Binary_Request_Handler
This commit is contained in:
@@ -26,6 +26,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
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.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.HOLDS_ALIAS;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_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.util.PojoUtility.toJson;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
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.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.BAD_REQUEST;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||||
@@ -42,7 +47,10 @@ import static org.testng.Assert.assertTrue;
|
|||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
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.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.requests.igCoreAPI.FilePlanComponentAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
|
import org.alfresco.utility.report.Bug;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@@ -246,4 +254,84 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
|||||||
// and end with its extension
|
// and end with its extension
|
||||||
assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf("."))));
|
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()
|
||||||
|
)
|
||||||
|
.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()));
|
||||||
|
|
||||||
|
//create the container structure relative to the categoryId
|
||||||
|
String categoryId = filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + CATEGORY_NAME)
|
||||||
|
.getId();
|
||||||
|
RELATIVE_PATH = CATEGORY_NAME + CATEGORY_NAME + "/" + 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