RM-2526 Add a second test for linking to a shorter schedule.

This commit is contained in:
Tom Page
2016-10-20 11:36:47 +01:00
parent e664784ce5
commit 92ea5c3b58

View File

@@ -13,7 +13,6 @@ 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.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.job.publish.DispositionActionDefinitionPublishExecutor;
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.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest;
@@ -37,8 +36,6 @@ public class MultipleSchedulesTest extends BaseRMTestCase
/** The name to use for the record. */
protected static final String RECORD_NAME = TEST_PREFIX + "Record";
/** The executor for the disposition update job. */
private DispositionActionDefinitionPublishExecutor dispositionActionDefinitionPublishExecutor;
/** The internal disposition service is used to avoid permissions issues when updating the record. */
private DispositionService internalDispositionService;
@@ -62,23 +59,24 @@ public class MultipleSchedulesTest extends BaseRMTestCase
// Get the application context
applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations());
dispositionActionDefinitionPublishExecutor = applicationContext.getBean(DispositionActionDefinitionPublishExecutor.class);
internalDispositionService = (DispositionService) applicationContext.getBean("dispositionService");
// Set up the file plan if it hasn't already been done.
if (categoryA == null)
{
setUpFilePlan();
}
// Ensure different records are used for each test.
record = null;
}
/**
* <a href="https://issues.alfresco.com/jira/browse/RM-2526">RM-2526</a>
* <p><pre>
* 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.
* </pre>
* Create two categories each containing a folder. Set up a schedule on category A that applies to records (cutoff
* immediately, destroy immediately). Set up a schedule on category B that is the same, but with a week delay before
* destroy becomes eligible.
*/
public void testLinkedToLongerSchedule()
private void setUpFilePlan()
{
test()
.given(() -> {
// Create two categories.
categoryA = filePlanService.createRecordCategory(filePlan, CATEGORY_A_NAME);
categoryB = filePlanService.createRecordCategory(filePlan, CATEGORY_B_NAME);
@@ -106,6 +104,21 @@ public class MultipleSchedulesTest extends BaseRMTestCase
// Create a folder within each category.
folderA = recordFolderService.createRecordFolder(categoryA, FOLDER_A_NAME);
folderB = recordFolderService.createRecordFolder(categoryB, FOLDER_B_NAME);
}
/**
* <a href="https://issues.alfresco.com/jira/browse/RM-2526">RM-2526</a>
* <p><pre>
* 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.
* </pre>
*/
public void testLinkedToLongerSchedule()
{
test()
.given(() -> {
// 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);
@@ -134,5 +147,22 @@ public class MultipleSchedulesTest extends BaseRMTestCase
*/
public void testLinkedToShorterSchedule()
{
test()
.given(() -> {
// 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);
})
.then()
.expect(7 * 24 * 60 * 60 * 1000L)
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate().getTime()
- ((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE)).getTime())
.because("Record should follow largest rentention schedule period, which is one week.");
}
}