mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2526 Add a second test for linking to a shorter schedule.
This commit is contained in:
@@ -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.action.impl.DestroyAction;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
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.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.BaseRMTestCase;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest;
|
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. */
|
/** The name to use for the record. */
|
||||||
protected static final String RECORD_NAME = TEST_PREFIX + "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. */
|
/** The internal disposition service is used to avoid permissions issues when updating the record. */
|
||||||
private DispositionService internalDispositionService;
|
private DispositionService internalDispositionService;
|
||||||
|
|
||||||
@@ -62,8 +59,51 @@ public class MultipleSchedulesTest extends BaseRMTestCase
|
|||||||
|
|
||||||
// Get the application context
|
// Get the application context
|
||||||
applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations());
|
applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations());
|
||||||
dispositionActionDefinitionPublishExecutor = applicationContext.getBean(DispositionActionDefinitionPublishExecutor.class);
|
|
||||||
internalDispositionService = (DispositionService) applicationContext.getBean("dispositionService");
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
private void setUpFilePlan()
|
||||||
|
{
|
||||||
|
// Create two categories.
|
||||||
|
categoryA = filePlanService.createRecordCategory(filePlan, CATEGORY_A_NAME);
|
||||||
|
categoryB = filePlanService.createRecordCategory(filePlan, CATEGORY_B_NAME);
|
||||||
|
// Create a disposition schedule for category A (Cut off immediately, then Destroy immediately).
|
||||||
|
DispositionSchedule dispSchedA = utils.createBasicDispositionSchedule(categoryA, "instructions", "authority", true, false);
|
||||||
|
Map<QName, Serializable> cutOffParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
|
||||||
|
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||||
|
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||||
|
dispositionService.addDispositionActionDefinition(dispSchedA, cutOffParamsA);
|
||||||
|
Map<QName, Serializable> destroyParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME,
|
||||||
|
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||||
|
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||||
|
dispositionService.addDispositionActionDefinition(dispSchedA, destroyParamsA);
|
||||||
|
// Create a disposition schedule for category B (Cut off immediately, then Destroy one week after cutoff).
|
||||||
|
DispositionSchedule dispSchedB = utils.createBasicDispositionSchedule(categoryB, "instructions", "authority", true, false);
|
||||||
|
Map<QName, Serializable> cutOffParamsB = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
|
||||||
|
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||||
|
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||||
|
dispositionService.addDispositionActionDefinition(dispSchedB, cutOffParamsB);
|
||||||
|
Map<QName, Serializable> 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,33 +119,6 @@ public class MultipleSchedulesTest extends BaseRMTestCase
|
|||||||
{
|
{
|
||||||
test()
|
test()
|
||||||
.given(() -> {
|
.given(() -> {
|
||||||
// Create two categories.
|
|
||||||
categoryA = filePlanService.createRecordCategory(filePlan, CATEGORY_A_NAME);
|
|
||||||
categoryB = filePlanService.createRecordCategory(filePlan, CATEGORY_B_NAME);
|
|
||||||
// Create a disposition schedule for category A (Cut off immediately, then Destroy immediately).
|
|
||||||
DispositionSchedule dispSchedA = utils.createBasicDispositionSchedule(categoryA, "instructions", "authority", true, false);
|
|
||||||
Map<QName, Serializable> cutOffParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
|
|
||||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
|
||||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
|
||||||
dispositionService.addDispositionActionDefinition(dispSchedA, cutOffParamsA);
|
|
||||||
Map<QName, Serializable> destroyParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME,
|
|
||||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
|
||||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
|
||||||
dispositionService.addDispositionActionDefinition(dispSchedA, destroyParamsA);
|
|
||||||
// Create a disposition schedule for category B (Cut off immediately, then Destroy one week after cutoff).
|
|
||||||
DispositionSchedule dispSchedB = utils.createBasicDispositionSchedule(categoryB, "instructions", "authority", true, false);
|
|
||||||
Map<QName, Serializable> cutOffParamsB = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
|
|
||||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
|
||||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
|
||||||
dispositionService.addDispositionActionDefinition(dispSchedB, cutOffParamsB);
|
|
||||||
Map<QName, Serializable> 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);
|
|
||||||
// Create a record filed under category A and linked to category B.
|
// Create a record filed under category A and linked to category B.
|
||||||
record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
|
record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
|
||||||
recordService.link(record, folderB);
|
recordService.link(record, folderB);
|
||||||
@@ -134,5 +147,22 @@ public class MultipleSchedulesTest extends BaseRMTestCase
|
|||||||
*/
|
*/
|
||||||
public void testLinkedToShorterSchedule()
|
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user