destroyParamsB = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME,
+ PROP_DISPOSITION_DESCRIPTION, "description",
+ PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_WEEK,
+ PROP_DISPOSITION_PERIOD_PROPERTY, PROP_CUT_OFF_DATE);
+ dispositionService.addDispositionActionDefinition(dispSchedB, destroyParamsB);
+ // Create a folder within each category.
+ folderA = recordFolderService.createRecordFolder(categoryA, FOLDER_A_NAME);
+ folderB = recordFolderService.createRecordFolder(categoryB, FOLDER_B_NAME);
+ }
+
+ /**
+ * RM-2526
+ *
+ * Given a record subject to a disposition schedule
+ * And it is linked to a disposition schedule with the same step order, but a longer destroy step
+ * When the record is moved onto the destroy step
+ * Then the "as of" date is calculated using the longer period.
+ *
+ */
+ public void testLinkedToLongerSchedule()
+ {
+ Calendar calendar = Calendar.getInstance();
+ test()
+ .given(() -> {
+ setUpFilePlan();
+ // Create a record filed under category A and linked to category B.
+ record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
+ recordService.link(record, folderB);
+ })
+ .when(() -> {
+ // Cut off the record.
+ dispositionService.cutoffDisposableItem(record);
+ // Ensure the update has been applied to the record.
+ internalDispositionService.updateNextDispositionAction(record);
+ calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
+ calendar.add(Calendar.WEEK_OF_YEAR, 1);
+ })
+ .then()
+ .expect(calendar.getTime())
+ .from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
+ .because("Record should follow largest rentention schedule period, which is one week.");
+ }
+
+ /**
+ * RM-2526
+ *
+ * Given a record subject to a disposition schedule
+ * And it is linked to a disposition schedule with the same step order, but a shorter destroy step
+ * When the record is moved onto the destroy step
+ * Then the "as of" date is calculated using the longer period.
+ *
+ */
+ public void testLinkedToShorterSchedule()
+ {
+ Calendar calendar = Calendar.getInstance();
+ test()
+ .given(() -> {
+ setUpFilePlan();
+ // Create a record filed under category B and linked to category A.
+ record = fileFolderService.create(folderB, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
+ recordService.link(record, folderA);
+ })
+ .when(() -> {
+ // Cut off the record.
+ dispositionService.cutoffDisposableItem(record);
+ // Ensure the update has been applied to the record.
+ internalDispositionService.updateNextDispositionAction(record);
+ calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
+ calendar.add(Calendar.WEEK_OF_YEAR, 1);
+ })
+ .then()
+ .expect(calendar.getTime())
+ .from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
+ .because("Record should follow largest rentention schedule period, which is one week.");
+ }
+}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java
new file mode 100644
index 0000000000..d8dbb0b078
--- /dev/null
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.disposition;
+
+import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION;
+import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS;
+import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME;
+import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.PERIOD_ONE_WEEK;
+import static org.alfresco.util.GUID.generate;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
+import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
+import org.alfresco.module.org_alfresco_module_rm.action.impl.EditDispositionActionAsOfDateAction;
+import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
+import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
+import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+
+/**
+* Update next disposition step integration tests.
+*
+* @author Roxana Lucanu
+* @since 2.3.1
+*/
+public class UpdateNextDispositionActionTest extends BaseRMTestCase
+{
+ /**
+ * Given a record with multiple dispositions
+ * When updating the next step
+ * Then the action is available
+ *
+ * relates to https://issues.alfresco.com/jira/browse/RM-3060
+ */
+ public void testUpdateNextDispositionAction_RM3060() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest()
+ {
+ NodeRef record;
+ NodeRef folder2;
+
+ @Override
+ public void given()
+ {
+ // create category1
+ NodeRef category1 = filePlanService.createRecordCategory(filePlan, generate());
+
+ // create disposition schedule for category1
+ createDispositionSchedule(category1);
+
+ // create category2
+ NodeRef category2 = filePlanService.createRecordCategory(filePlan, generate());
+
+ // create disposition schedule for category2
+ createDispositionSchedule(category2);
+
+ // create folder2 inside category2
+ folder2 = recordFolderService.createRecordFolder(category2, generate());
+
+ // create folder1 inside category1
+ NodeRef folder1 = recordFolderService.createRecordFolder(category1, generate());
+
+ // create record inside folder1
+ record = utils.createRecord(folder1, generate(), generate());
+
+ }
+ @Override
+ public void when() throws Exception
+ {
+ // link the record to folder2
+ recordService.link(record, folder2);
+
+ // complete record
+ utils.completeRecord(record);
+
+ // cut off
+ rmActionService.executeRecordsManagementAction(record, CutOffAction.NAME, null);
+ }
+
+ @Override
+ public void then() throws Exception
+ {
+ assertTrue("Record " + record + " doesn't have the cutOff aspect.", nodeService.hasAspect(record, ASPECT_CUT_OFF));
+ }
+ });
+ }
+
+ private void createDispositionSchedule(NodeRef category)
+ {
+ DispositionSchedule ds = utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_DESCRIPTION, true, false, false);
+
+ // create the properties for CUTOFF action and add it to the disposition action definition
+ Map cutOff = new HashMap(3);
+ cutOff.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
+ cutOff.put(PROP_DISPOSITION_DESCRIPTION, generate());
+ cutOff.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
+ dispositionService.addDispositionActionDefinition(ds, cutOff);
+
+ // create the properties for TRANSFER action and add it to the disposition action definition
+ Map transfer = new HashMap(3);
+ transfer.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME);
+ transfer.put(PROP_DISPOSITION_DESCRIPTION, generate());
+ transfer.put(PROP_DISPOSITION_EVENT, (Serializable)Collections.singletonList(DEFAULT_EVENT_NAME));
+ dispositionService.addDispositionActionDefinition(ds, transfer);
+
+ // create the properties for DESTROY action and add it to the disposition action definition
+ Map destroy = new HashMap(3);
+ destroy.put(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME);
+ destroy.put(PROP_DISPOSITION_DESCRIPTION, generate());
+ destroy.put(PROP_DISPOSITION_PERIOD, PERIOD_ONE_WEEK);
+ dispositionService.addDispositionActionDefinition(ds, destroy);
+ }
+}
\ No newline at end of file
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java
index 5e5dd27b0a..30ff940467 100755
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java
@@ -42,7 +42,6 @@ import org.junit.runners.Suite.SuiteClasses;
RM452Test.class,
RM804Test.class,
RM994Test.class,
- RM1039Test.class,
RM1799Test.class,
RM1814Test.class,
RM978Test.class,
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java
deleted file mode 100644
index 8ef86eef6e..0000000000
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2005-2013 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.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.acegisecurity.vote.AccessDecisionVoter;
-
-import org.alfresco.model.ContentModel;
-import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
-import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
-import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
-import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
-import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
-import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
-import org.alfresco.service.cmr.repository.NodeRef;
-
-
-/**
- * Unit test for RM-1039 ... can't move a folder into a category with a disposition schedule
- *
- * @author Roy Wetherall
- * @since 2.1
- */
-public class RM1039Test extends BaseRMTestCase
-{
- @Override
- protected boolean isRecordTest()
- {
- return true;
- }
-
- // try and move a folder from no disposition schedule to a disposition schedule
- public void testMoveRecordFolderFromNoDisToDis() throws Exception
- {
- final NodeRef recordFolder = doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run()
- {
- // create a record category (no disposition schedule)
- NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
-
- // create a record folder
- return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall");
- }
-
- @Override
- public void test(NodeRef result) throws Exception
- {
- assertNotNull(result);
- assertNull(dispositionService.getDispositionSchedule(result));
- assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
- }
- });
-
- final NodeRef record = doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run()
- {
- // create a record
- return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef();
- }
-
- @Override
- public void test(NodeRef result) throws Exception
- {
- assertNotNull(result);
- assertNull(dispositionService.getDispositionSchedule(result));
- assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
- }
- });
-
- doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run() throws Exception
- {
- Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders");
- assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder));
- assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer));
-
- // take a look at the move capability
- Capability moveCapability = capabilityService.getCapability("Move");
- assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer));
-
- // move the node
- return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef();
- }
-
- @Override
- public void test(NodeRef result) throws Exception
- {
- assertNotNull(result);
- assertNotNull(dispositionService.getDispositionSchedule(result));
- assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
-
- DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result);
- assertNotNull(dispositionAction);
-
- assertNull(dispositionAction.getAsOfDate());
- assertEquals("cutoff", dispositionAction.getName());
- assertEquals(1, dispositionAction.getEventCompletionDetails().size());
-
- // take a look at the record and check things are as we would expect
- assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
- }
- });
- }
-
- // move from a disposition schedule to another .. both record folder level
-
- // move from a disposition schedule to another .. from record to folder level
-
-
- // try and move a cutoff folder
- public void testMoveCutoffRecordFolder() throws Exception
- {
- final NodeRef destination = doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run()
- {
- // create a record category (no disposition schedule)
- return filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
- }
- });
-
- final NodeRef testFolder = doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run()
- {
- // create folder
- NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis");
-
- // complete event
- Map params = new HashMap(1);
- params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
- rmActionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params);
-
- // cutoff folder
- rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME);
-
- return testFolder;
- }
-
- @Override
- public void test(NodeRef result) throws Exception
- {
- // take a look at the move capability
- Capability moveCapability = capabilityService.getCapability("Move");
- assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(result, destination));
-
- }
- });
-
- doTestInTransaction(new FailureTest()
- {
- @Override
- public void run() throws Exception
- {
- fileFolderService.move(testFolder, destination, null).getNodeRef();
- }
- });
- }
-}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java
index d8ecd511ed..328a31b5e6 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java
@@ -384,9 +384,12 @@ public class MoveRecordFolderTest extends BaseRMTestCase
}
});
}
-
-
- // try and move a cutoff folder
+
+ /**
+ * Try and move a cutoff folder
+ *
+ * @see https://issues.alfresco.com/jira/browse/RM-1039
+ */
public void testMoveCutoffRecordFolder() throws Exception
{
final NodeRef destination = doTestInTransaction(new Test()
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java
index e3853bfc30..29ab764296 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java
@@ -657,7 +657,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase
checkDisposableItemChanged(mhRecordFolder42);
checkDisposableItemChanged(record43);
checkDisposableItemUnchanged(mhRecordFolder44);
- checkDisposableItemUnchanged(record45);;
+ checkDisposableItemUnchanged(record45);
}
});
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java
index 275dc089da..c7b0d2ef99 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java
@@ -76,6 +76,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
public static final String DEFAULT_EVENT_NAME = "case_closed";
public static final String PERIOD_NONE = "none|0";
public static final String PERIOD_IMMEDIATELY = "immediately|0";
+ public static final String PERIOD_ONE_WEEK = "week|1";
public static final String PERIOD_ONE_YEAR = "year|1";
public static final String PERIOD_THREE_YEARS = "year|3";
diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java
index 76b0f0cf11..38e0a3e4f6 100755
--- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java
+++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java
@@ -263,7 +263,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class);
when(recordDispositionSchedule.isRecordLevelDisposition())
.thenReturn(true);
- when(mockedDispositionService.getDispositionSchedule(record))
+ when(mockedDispositionService.getOriginDispositionSchedule(record))
.thenReturn(recordDispositionSchedule);
DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class);