From d34754fb7c5342378eaddf1984df56c90ff9caff Mon Sep 17 00:00:00 2001 From: Ramona Popa Date: Fri, 19 May 2017 18:14:38 +0100 Subject: [PATCH] Feature/rm 5148 create folder and records using auto rename --- .../recordfolders/ElectronicRecordTests.java | 30 ++++++++++++++++++- .../NonElectronicRecordTests.java | 4 +-- .../api/impl/FilePlanComponentsApiUtils.java | 8 +---- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/ElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/ElectronicRecordTests.java index fcb34ae859..b8f0bbe9a9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/ElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/ElectronicRecordTests.java @@ -49,7 +49,6 @@ import static org.testng.Assert.assertTrue; import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.record.Record; -import org.alfresco.rest.rm.community.model.record.RecordContent; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; @@ -393,4 +392,33 @@ public class ElectronicRecordTests extends BaseRMRestTest assertTrue(unfiledRecordFoldersAPI.getUnfiledRecordFolder(record.getParentId()).getName().equals(unfiledRecordFolderPathEl4)); } + + /** + *
+     * Given a parent container that is a record folder
+     * When I try to create a record with name1 and create another one with the same given name
+     * Then the second record is created with success
+     * 
+ * + * @throws Exception + * if record can't be created + */ + @Test(description = "Electronic records can be created in record folder with duplicate name") + @Bug(id ="RM-5116, RM-5012") + public void canCreateElectronicRecordsWithDuplicateName() throws Exception + { + RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); + + // Create an electronic record with the name "Record 1" + Record recordModel = Record.builder().name("Record 1").nodeType(CONTENT_TYPE).build(); + getRestAPIFactory().getRecordFolderAPI().createRecord(recordModel, recordFolder.getId()); + // Verify the status code + assertStatusCode(CREATED); + + // Try to create another electronic record with the same name + getRestAPIFactory().getRecordFolderAPI().createRecord(recordModel, recordFolder.getId()); + + // Verify the status code + assertStatusCode(CREATED); + } } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/NonElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/NonElectronicRecordTests.java index 0c022e09b3..3794140bd2 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/NonElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/NonElectronicRecordTests.java @@ -33,9 +33,9 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.util.PojoUtility.toJson; -import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel; -import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createFullNonElectronicUnfiledContainerChildRecordModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createFullNonElectronicRecordModel; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createFullNonElectronicUnfiledContainerChildRecordModel; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.verifyFullNonElectronicRecord; import static org.alfresco.utility.constants.UserRole.SiteManager; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java index a6caf3b599..5f5193f283 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java @@ -136,12 +136,6 @@ public class FilePlanComponentsApiUtils RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, RecordsManagementModel.TYPE_HOLD_CONTAINER); - public static final List TYPES_CAN_USE_AUTORENAME = Arrays.asList( - RecordsManagementModel.TYPE_RECORD_CATEGORY, - RecordsManagementModel.TYPE_RECORD_FOLDER, - RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER, - RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER); - /** RM Nodes API */ private Nodes nodes; private FileFolderService fileFolderService; @@ -630,7 +624,7 @@ public class FilePlanComponentsApiUtils QName typeQName = nodes.createQName(nodeType); // Existing file/folder name handling - if (TYPES_CAN_USE_AUTORENAME.contains(typeQName) && autoRename) + if (autoRename) { NodeRef existingNode = nodeService.getChildByName(parentNodeRef, ContentModel.ASSOC_CONTAINS, nodeName); if (existingNode != null)