RM-3265 Add test for the Move action on a destroyed record folder.

This commit is contained in:
Roxana Dina
2016-06-22 20:27:26 +03:00
parent 4b0ffc272d
commit e0db9fbb05

View File

@@ -34,6 +34,7 @@ import java.util.Map;
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.action.impl.DestroyAction;
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.disposition.DispositionSchedule;
@@ -61,8 +62,8 @@ public class MoveRecordFolderTest extends BaseRMTestCase
}
/**
* Given two categories, both with cut off immediately schedules, when the record is move
* then all the parts of the record should be correct based on the new schedule.
* Given two categories, both with cut off immediately schedules, when the record is move then all the parts of the
* record should be correct based on the new schedule.
*
* @see https://issues.alfresco.com/jira/browse/RM-1345
*/
@@ -101,7 +102,8 @@ public class MoveRecordFolderTest extends BaseRMTestCase
{
// check the search aspect properties
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
assertEquals(CutOffAction.NAME,
nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF));
}
});
@@ -137,7 +139,8 @@ public class MoveRecordFolderTest extends BaseRMTestCase
// check the search aspect properties
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
assertEquals(CutOffAction.NAME,
nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF));
}
});
@@ -183,7 +186,8 @@ public class MoveRecordFolderTest extends BaseRMTestCase
{
// check the search aspect properties
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
assertEquals(CutOffAction.NAME,
nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF));
}
});
@@ -263,7 +267,8 @@ public class MoveRecordFolderTest extends BaseRMTestCase
{
// check the search aspect properties
assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH));
assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME));
assertEquals(CutOffAction.NAME,
nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
}
});
@@ -301,7 +306,8 @@ public class MoveRecordFolderTest extends BaseRMTestCase
// check the search aspect properties
assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH));
assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME));
assertEquals(CutOffAction.NAME,
nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
}
});
@@ -394,7 +400,6 @@ public class MoveRecordFolderTest extends BaseRMTestCase
});
}
// try and move a cutoff folder
public void testMoveCutoffRecordFolder() throws Exception
{
@@ -446,11 +451,66 @@ public class MoveRecordFolderTest extends BaseRMTestCase
});
}
// try and move a destroyed folder
public void testMoveDestroyedRecordFolder() throws Exception
{
final NodeRef destination = doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run()
{
// create a record category (no disposition schedule)
return filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
}
});
final NodeRef testFolder = doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run()
{
// create folder
NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis");
// complete event
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
rmActionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params);
// cutoff & destroy folder
rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME);
rmActionService.executeRecordsManagementAction(testFolder, DestroyAction.NAME);
return testFolder;
}
});
doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run() throws Exception
{
Capability moveCapability = capabilityService.getCapability("MoveRecordFolder");
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(testFolder, destination));
return fileFolderService.move(testFolder, destination, null).getNodeRef();
}
@Override
public void test(NodeRef result) throws Exception
{
assertNotNull(result);
}
});
}
private NodeRef createRecordCategory(boolean recordLevel)
{
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
DispositionSchedule dis = utils.createBasicDispositionSchedule(rc, GUID.generate(), GUID.generate(), recordLevel, false);
DispositionSchedule dis = utils.createBasicDispositionSchedule(rc, GUID.generate(), GUID.generate(),
recordLevel, false);
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate());