diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java index 643bef70ff..ba9b8b9f5b 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java @@ -157,6 +157,7 @@ public class FilePlanComponentAPI extends RestAPI public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, File recordContent, String parentId) throws Exception { mandatoryObject("filePlanComponentProperties", electronicRecordModel); + mandatoryString("parentId", parentId); if (!electronicRecordModel.getNodeType().equals(FilePlanComponentType.CONTENT_TYPE.toString())) { fail("Only electronic records are supported"); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java index 3fa9973b24..96362a07bd 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java @@ -30,10 +30,12 @@ import static java.lang.Integer.parseInt; import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_TITLE; import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD; +import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.OK; @@ -48,6 +50,7 @@ import org.alfresco.rest.rm.community.model.site.RMSite; import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; import org.alfresco.rest.rm.community.requests.RMSiteAPI; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @@ -212,4 +215,34 @@ public class BaseRestTest extends RestTest return updatedComponent; } + /** + * Helper method to create a randomly-named / structure in fileplan + * @param user user under whose privileges this structure is going to be created + * @param parentId parent container id + * @return record folder + * @throws Exception on failed creation + */ + public FilePlanComponent createFolderInFilePlan(UserModel user, String parentId) throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(user); + + // create root category + FilePlanComponent recordCategory = createCategory(parentId, "Category " + getRandomAlphanumeric()); + + // and return a folder underneath + return createFolder(recordCategory.getId(), "Folder " + getRandomAlphanumeric()); + } + + /** + * Helper method to retieve a fileplan component with user's privilege + * @param user user under whose privileges a component is to be read + * @param componentId id of the component to read + * @return {@link FilePlanComponent} for given componentId + * @throws Exception if user doesn't have sufficient privileges + */ + public FilePlanComponent getFilePlanComponentAsUser(UserModel user, String componentId) throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(user); + return filePlanComponentAPI.getFilePlanComponent(componentId); + } } \ No newline at end of file diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java index 69c197ea90..6990e1f319 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java @@ -83,7 +83,7 @@ public class NonElectronicRecordTests extends BaseRestTest // an arbitrary record folder { createFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, // unfiled records root - { filePlanComponentAPI.getFilePlanComponent(UNFILED_RECORDS_CONTAINER_ALIAS.toString()) }, + { getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) }, // an arbitrary unfiled records folder { createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()) } }; @@ -363,22 +363,6 @@ public class NonElectronicRecordTests extends BaseRestTest return component; } - /** - * Helper method to create a randomly-named / structure in fileplan - * @return record folder - * @throws Exception on failed creation - */ - private FilePlanComponent createFolderInFilePlan(UserModel user, String parentId) throws Exception - { - filePlanComponentAPI.usingRestWrapper().authenticateUser(user); - - // create root category - FilePlanComponent recordCategory = createCategory(parentId, "Category " + getRandomAlphanumeric()); - - // and return a folder underneath - return createFolder(recordCategory.getId(), "Folder " + getRandomAlphanumeric()); - } - /** * Create user with given role and add it to RM site *