use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction in project records-management by Alfresco.
the class MoveRecordFolderTest method testMoveRecordFolderFromNoDisToDis.
/**
* Try and move a folder from no disposition schedule to a disposition schedule
*
* @see https://issues.alfresco.com/jira/browse/RM-1039
*/
public void testMoveRecordFolderFromNoDisToDis() throws Exception {
final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>() {
@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));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
}
});
final NodeRef record = doTestInTransaction(new Test<NodeRef>() {
@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));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
}
});
doTestInTransaction(new Test<NodeRef>() {
@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));
}
});
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction in project records-management by Alfresco.
the class BroadcastDispositionActionDefinitionUpdateActionUnitTest method testPersistPeriodChanges.
/**
* Check that the disposition service is used to determine the "disposition as of" date when changes are made to the
* disposition period.
*/
@Test
public void testPersistPeriodChanges() {
// Set up the data associated with the next disposition action.
DispositionAction mockAction = mock(DispositionAction.class);
when(mockAction.getNodeRef()).thenReturn(NEXT_ACTION_NODE_REF);
DispositionActionDefinition mockDispositionActionDefinition = mock(DispositionActionDefinition.class);
when(mockAction.getDispositionActionDefinition()).thenReturn(mockDispositionActionDefinition);
when(mockAction.getName()).thenReturn("mockAction");
// Set up the disposition service to return a known "disposition as of" date.
Date asOfDate = new Date();
when(mockDispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition)).thenReturn(asOfDate);
// Call the method under test.
action.persistPeriodChanges(DISPOSITION_ACTION_DEF_NODE, mockAction);
// Check that the "disposition as of" date has been set on the next action.
verify(mockNodeService).setProperty(NEXT_ACTION_NODE_REF, PROP_DISPOSITION_AS_OF, asOfDate);
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction in project records-management by Alfresco.
the class DispositionServiceImplTest method testRM_263.
/**
* https://issues.alfresco.com/jira/browse/RM-263
*/
public void testRM_263() throws Exception {
doTestInTransaction(new Test<Void>() {
@Override
public Void run() throws Exception {
testRM263RecordCategory = filePlanService.createRecordCategory(rmContainer, "rm263");
testRM263DispositionSchedule = utils.createBasicDispositionSchedule(testRM263RecordCategory, "test", "test", true, false);
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff");
adParams.put(PROP_DISPOSITION_DESCRIPTION, "test");
adParams.put(PROP_DISPOSITION_PERIOD, "week|1");
adParams.put(PROP_DISPOSITION_PERIOD_PROPERTY, DOD5015Model.PROP_PUBLICATION_DATE.toString());
dispositionService.addDispositionActionDefinition(testRM263DispositionSchedule, adParams);
NodeRef recordFolder = recordFolderService.createRecordFolder(testRM263RecordCategory, "testRM263RecordFolder");
testRM263Record = utils.createRecord(recordFolder, "testRM263Record", "testRM263Record");
return null;
}
});
doTestInTransaction(new Test<Void>() {
private final QName PROP_SEARCH_ASOF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf");
@Override
public Void run() throws Exception {
Date pubDate = (Date) nodeService.getProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE);
assertNull(pubDate);
Date asOfDate = (Date) nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF);
assertNull(asOfDate);
DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record);
assertNotNull(da);
assertNull(da.getAsOfDate());
// rma:recordSearchDispositionActionAsOf"
nodeService.setProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE, new Date());
return null;
}
@Override
public void test(Void result) throws Exception {
Date pubDate = (Date) nodeService.getProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE);
assertNotNull(pubDate);
Date asOfDate = (Date) nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF);
assertNotNull(asOfDate);
DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record);
assertNotNull(da);
assertNotNull(da.getAsOfDate());
}
});
}
Aggregations