diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1424Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1424Test.java new file mode 100644 index 0000000000..d38f28f694 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1424Test.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.test.service.HoldServiceImplTest; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unit test for https://issues.alfresco.com/jira/browse/RM-1424 + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class RM1424Test extends HoldServiceImplTest +{ + public void testGettingHolds() + { + final List listWithTwoHolds = new ArrayList(2); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // No holds + List emptyHoldList = holdService.getHolds(filePlan); + assertNotNull(emptyHoldList); + assertTrue(emptyHoldList.isEmpty()); + + // Create 2 holds + createAndCheckHolds(); + + // Check the list of holds + listWithTwoHolds.addAll(holdService.getHolds(filePlan)); + assertNotNull(listWithTwoHolds); + assertEquals(2, listWithTwoHolds.size()); + + // Check the first hold + NodeRef hold1 = listWithTwoHolds.get(0); + assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold1)); + assertEquals(HOLD1_NAME, (String) nodeService.getProperty(hold1, PROP_NAME)); + assertEquals(HOLD1_REASON, (String) nodeService.getProperty(hold1, PROP_HOLD_REASON)); + assertEquals(HOLD1_DESC, (String) nodeService.getProperty(hold1, PROP_DESCRIPTION)); + + // Add the user to the RM Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName); + + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Get the holds the test user without having any permissions on the holds + List holds = holdService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(0, holds.size()); + + return null; + } + }, userName); + + final NodeRef hold2 = listWithTwoHolds.get(1); + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Give the user read permissions on the hold + permissionService.setPermission(hold2, userName, RMPermissionModel.FILING, true); + + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + List holds = holdService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(1, holds.size()); + assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold2)); + assertEquals(HOLD2_NAME, (String) nodeService.getProperty(hold2, PROP_NAME)); + assertEquals(HOLD2_REASON, (String) nodeService.getProperty(hold2, PROP_HOLD_REASON)); + assertEquals(HOLD2_DESC, (String) nodeService.getProperty(hold2, PROP_DESCRIPTION)); + + return null; + } + }, userName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1429.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1429.java new file mode 100644 index 0000000000..e0e6a377dc --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1429.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.service.HoldServiceImplTest; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unit test for https://issues.alfresco.com/jira/browse/RM-1429 + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class RM1429 extends HoldServiceImplTest +{ + public void testDeleteHoldWithoutPermissionsOnChildren() + { + // Create the test hold + final NodeRef hold = createAndCheckHold(); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add the user to the RM Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName); + + // Give the user filing permissions on the hold + permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true); + + // Give the user read permissions on the record folder + permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true); + + // Add record folder to the hold + holdService.addToHold(hold, rmFolder); + + return null; + } + }); + + doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) + { + @Override + public void run() + { + holdService.deleteHold(hold); + } + }, userName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1463Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1463Test.java new file mode 100644 index 0000000000..c202070f67 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1463Test.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.service.HoldServiceImplTest; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unit test for https://issues.alfresco.com/jira/browse/RM-1463 + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class RM1463Test extends HoldServiceImplTest +{ + public void testAddRecordFolderToHoldWithoutFilingPermissionOnRecordFolder() + { + // Create hold + final NodeRef hold = createAndCheckHold(); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add the user to the RM Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName); + + // Give the user filing permissions on the hold + permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true); + + // Give the user only read permissions on the record folder + permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true); + + return null; + } + }); + + doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) + { + @Override + public void run() + { + holdService.addToHold(hold, rmFolder); + } + }, userName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1464Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1464Test.java new file mode 100644 index 0000000000..1a6fbe96a3 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1464Test.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.test.service.HoldServiceImplTest; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Unit test for https://issues.alfresco.com/jira/browse/RM-1464 + * + * @author Tuna Aksoy + * @since 2.2 + * @version 1.0 + */ +public class RM1464Test extends HoldServiceImplTest +{ + public void testAddRecordFolderToHoldWithoutFilingPermissionOnHold() + { + // Create hold + final NodeRef hold = createAndCheckHold(); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // Add the user to the RM Manager role + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName); + + // Give the user read permissions on the hold + permissionService.setPermission(hold, userName, RMPermissionModel.READ_RECORDS, true); + + // Give the user filing permissions on the record folder + permissionService.setPermission(rmFolder, userName, RMPermissionModel.FILING, true); + + return null; + } + }); + + doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) + { + @Override + public void run() + { + holdService.addToHold(hold, rmFolder); + } + }, userName); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/HoldServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/HoldServiceImplTest.java index d343044036..f99e78d5b5 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/HoldServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/HoldServiceImplTest.java @@ -21,9 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.test.service; import java.util.ArrayList; import java.util.List; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; import org.alfresco.service.cmr.repository.NodeRef; @@ -36,12 +33,12 @@ import org.alfresco.service.cmr.repository.NodeRef; public class HoldServiceImplTest extends BaseRMTestCase { /** Constants for the holds */ - private static final String HOLD1_NAME = "hold one"; - private static final String HOLD2_NAME = "hold two"; - private static final String HOLD1_REASON = "I have my reasons"; - private static final String HOLD2_REASON = "secrets are everything"; - private static final String HOLD1_DESC = "but I'll not describe them here!"; - private static final String HOLD2_DESC = "no then! that's just not on!"; + protected static final String HOLD1_NAME = "hold one"; + protected static final String HOLD2_NAME = "hold two"; + protected static final String HOLD1_REASON = "I have my reasons"; + protected static final String HOLD2_REASON = "secrets are everything"; + protected static final String HOLD1_DESC = "but I'll not describe them here!"; + protected static final String HOLD2_DESC = "no then! that's just not on!"; @Override protected boolean isRecordTest() @@ -60,7 +57,7 @@ public class HoldServiceImplTest extends BaseRMTestCase * * @return {@link NodeRef} Node reference of the hold. */ - private NodeRef createAndCheckHold() + protected NodeRef createAndCheckHold() { NodeRef hold = holdService.createHold(filePlan, HOLD1_NAME, HOLD1_REASON, HOLD1_DESC); assertNotNull(hold); @@ -72,7 +69,7 @@ public class HoldServiceImplTest extends BaseRMTestCase * * @return List of {@link NodeRef}s of the holds. */ - private List createAndCheckHolds() + protected List createAndCheckHolds() { List holds = new ArrayList(2); holds.add(createAndCheckHold()); @@ -183,153 +180,6 @@ public class HoldServiceImplTest extends BaseRMTestCase }); } - public void testAddRecordFolderToHoldWithoutFilingPermissionOnRecordFolder() - { - // Create hold - final NodeRef hold = createAndCheckHold(); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Add the user to the RM Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName); - - // Give the user filing permissions on the hold - permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true); - - // Give the user only read permissions on the record folder - permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true); - - return null; - } - }); - - doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) - { - @Override - public void run() throws Exception - { - holdService.addToHold(hold, rmFolder); - } - }, userName); - } - - public void testAddRecordFolderToHoldWithoutFilingPermissionOnHold() - { - // Create hold - final NodeRef hold = createAndCheckHold(); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Add the user to the RM Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName); - - // Give the user read permissions on the hold - permissionService.setPermission(hold, userName, RMPermissionModel.READ_RECORDS, true); - - // Give the user filing permissions on the record folder - permissionService.setPermission(rmFolder, userName, RMPermissionModel.FILING, true); - - return null; - } - }); - - doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) - { - @Override - public void run() throws Exception - { - holdService.addToHold(hold, rmFolder); - } - }, userName); - } - - public void testGettingHolds() - { - final List listWithTwoHolds = new ArrayList(2); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // No holds - List emptyHoldList = holdService.getHolds(filePlan); - assertNotNull(emptyHoldList); - assertTrue(emptyHoldList.isEmpty()); - - // Create 2 holds - createAndCheckHolds(); - - // Check the list of holds - listWithTwoHolds.addAll(holdService.getHolds(filePlan)); - assertNotNull(listWithTwoHolds); - assertEquals(2, listWithTwoHolds.size()); - - // Check the first hold - NodeRef hold1 = listWithTwoHolds.get(0); - assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold1)); - assertEquals(HOLD1_NAME, (String) nodeService.getProperty(hold1, PROP_NAME)); - assertEquals(HOLD1_REASON, (String) nodeService.getProperty(hold1, PROP_HOLD_REASON)); - assertEquals(HOLD1_DESC, (String) nodeService.getProperty(hold1, PROP_DESCRIPTION)); - - // Add the user to the RM Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Get the holds the test user without having any permissions on the holds - List holds = holdService.getHolds(filePlan); - assertNotNull(holds); - assertEquals(0, holds.size()); - - return null; - } - }, userName); - - final NodeRef hold2 = listWithTwoHolds.get(1); - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Give the user read permissions on the hold - permissionService.setPermission(hold2, userName, RMPermissionModel.FILING, true); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - List holds = holdService.getHolds(filePlan); - assertNotNull(holds); - assertEquals(1, holds.size()); - assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold2)); - assertEquals(HOLD2_NAME, (String) nodeService.getProperty(hold2, PROP_NAME)); - assertEquals(HOLD2_REASON, (String) nodeService.getProperty(hold2, PROP_HOLD_REASON)); - assertEquals(HOLD2_DESC, (String) nodeService.getProperty(hold2, PROP_DESCRIPTION)); - - return null; - } - }, userName); - } - public void testHeldByNothing() { doTestInTransaction(new Test() @@ -360,40 +210,4 @@ public class HoldServiceImplTest extends BaseRMTestCase } }); } - - public void testDeleteHoldWithoutPermissionsOnChildren() - { - // Create the test hold - final NodeRef hold = createAndCheckHold(); - - doTestInTransaction(new Test() - { - @Override - public Void run() throws Exception - { - // Add the user to the RM Manager role - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName); - - // Give the user filing permissions on the hold - permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true); - - // Give the user read permissions on the record folder - permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true); - - // Add record folder to the hold - holdService.addToHold(hold, rmFolder); - - return null; - } - }); - - doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class) - { - @Override - public void run() throws Exception - { - holdService.deleteHold(hold); - } - }, userName); - } }