diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4619Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4619Test.java new file mode 100644 index 0000000000..6b83327468 --- /dev/null +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4619Test.java @@ -0,0 +1,84 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2017 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.model.FileInfo; +import org.springframework.extensions.webscripts.GUID; + +/** + * Unit test for RM-4619 + * + * When creating regular folders through clients that are not RM aware + * the folders must be converted to the appropriate RM container + * + * @author Ana Bozianu + * @since 2.6 + */ +public class RM4619Test extends BaseRMTestCase +{ + + /** + * Given the RM site is created + * When we create a regular folder in the fileplan + * Then the folder is immediately converted to a record category + */ + public void testConvertFolderToCategory() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + FileInfo info = fileFolderService.create(filePlan, GUID.generate(), TYPE_FOLDER); + assertEquals(info.getType(), TYPE_RECORD_CATEGORY); + return null; + } + + }, ADMIN_USER); + } + + /** + * Given an existing category + * When we create a regular folder in the category + * Then the folder is immediately converted to a record folder + */ + public void testConvertFolderToRecordFolder() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + FileInfo info = fileFolderService.create(rmContainer, GUID.generate(), TYPE_FOLDER); + assertEquals(info.getType(), TYPE_RECORD_FOLDER); + return null; + } + + }, ADMIN_USER); + } +} diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanTypeUnitTest.java index d25d6ecb19..d5fa40ae74 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanTypeUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanTypeUnitTest.java @@ -182,29 +182,6 @@ public class FilePlanTypeUnitTest extends BaseUnitTest filePlanType.onCreateChildAssociation(childAssoc, true); } - /** - * Given that we try to add "cm:folder" type to a record category, - * Then operation is successful and the folder is automatically converted to a record folder - */ - @Test - public void testConversionToRecordFolder() throws Exception - { - NodeRef fileplan = AlfMock.generateNodeRef(mockedNodeService, TYPE_FILE_PLAN); - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER, true); - ChildAssociationRef childAssocRef = generateChildAssociationRef(fileplan, nodeRef); - - try - { - filePlanType.onCreateChildAssociation(childAssocRef, true); - } - catch(IntegrityException ex) - { - // this will throw an exception because unit tests can't detect type change - } - - verify(mockedNodeService).setType(nodeRef, TYPE_RECORD_CATEGORY); - } - /** * Helper method that creates a child of the fileplan container with the provided type * @param childType the node type of the child to be created diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryTypeUnitTest.java index 2560615bca..db00723660 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryTypeUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryTypeUnitTest.java @@ -109,27 +109,4 @@ public class RecordCategoryTypeUnitTest extends BaseUnitTest ChildAssociationRef childAssocRef = generateChildAssociationRef(recordCategoryNodeRef, nodeRef); recordCategoryType.onCreateChildAssociation(childAssocRef, true); } - - /** - * Given that we try to add "cm:folder" type to a record category, - * Then operation is successful and the folder is automatically converted to a record folder - */ - @Test - public void testConversionToRecordFolder() throws Exception - { - NodeRef recordCategoryNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_CATEGORY); - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER, true); - ChildAssociationRef childAssocRef = generateChildAssociationRef(recordCategoryNodeRef, nodeRef); - - try - { - recordCategoryType.onCreateChildAssociation(childAssocRef, true); - } - catch(IntegrityException ex) - { - // this will throw an exception because unit tests can't detect type change - } - - verify(mockedNodeService).setType(nodeRef, TYPE_RECORD_FOLDER); - } }