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.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; 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.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.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
@@ -48,31 +49,31 @@ import net.sf.acegisecurity.vote.AccessDecisionVoter;
/** /**
* Move record folder tests. * Move record folder tests.
* *
* @author Roy Wetherall * @author Roy Wetherall
* @since 2.2 * @since 2.2
*/ */
public class MoveRecordFolderTest extends BaseRMTestCase public class MoveRecordFolderTest extends BaseRMTestCase
{ {
@Override @Override
protected boolean isRecordTest() protected boolean isRecordTest()
{ {
return true; return true;
} }
/** /**
* Given two categories, both with cut off immediately schedules, when the record is move * Given two categories, both with cut off immediately schedules, when the record is move then all the parts of the
* then all the parts of the record should be correct based on the new schedule. * record should be correct based on the new schedule.
* *
* @see https://issues.alfresco.com/jira/browse/RM-1345 * @see https://issues.alfresco.com/jira/browse/RM-1345
*/ */
public void testMoveRecordFolderBeforeCutOffFolderLevelDisposition() throws Exception public void testMoveRecordFolderBeforeCutOffFolderLevelDisposition() throws Exception
{ {
doBehaviourDrivenTest(new BehaviourDrivenTest(null, false) doBehaviourDrivenTest(new BehaviourDrivenTest(null, false)
{ {
NodeRef recordFolder; NodeRef recordFolder;
NodeRef destinationRecordCategory; NodeRef destinationRecordCategory;
public void given() public void given()
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
@@ -82,43 +83,44 @@ public class MoveRecordFolderTest extends BaseRMTestCase
NodeRef rcOne = createRecordCategory(false); NodeRef rcOne = createRecordCategory(false);
destinationRecordCategory = createRecordCategory(false); destinationRecordCategory = createRecordCategory(false);
recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate()); recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate());
// check for the lifecycle aspect // check for the lifecycle aspect
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
// check the disposition action details // check the disposition action details
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
assertNotNull(dispositionAction); assertNotNull(dispositionAction);
assertNotNull(CutOffAction.NAME, dispositionAction.getName()); assertNotNull(CutOffAction.NAME, dispositionAction.getName());
assertNotNull(dispositionAction.getAsOfDate()); assertNotNull(dispositionAction.getAsOfDate());
assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
} }
}); });
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
{ {
public void runImpl() throws Exception public void runImpl() throws Exception
{ {
// check the search aspect properties // check the search aspect properties
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); 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)); assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF));
} }
}); });
} }
public void when() throws Exception public void when() throws Exception
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
{ {
public void runImpl() throws Exception public void runImpl() throws Exception
{ {
// move record folder // move record folder
fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate()); fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate());
} }
}); });
} }
public void then() public void then()
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
@@ -127,34 +129,35 @@ public class MoveRecordFolderTest extends BaseRMTestCase
{ {
// check for the lifecycle aspect // check for the lifecycle aspect
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
// check the disposition action details // check the disposition action details
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
assertNotNull(dispositionAction); assertNotNull(dispositionAction);
assertNotNull(CutOffAction.NAME, dispositionAction.getName()); assertNotNull(CutOffAction.NAME, dispositionAction.getName());
assertNotNull(dispositionAction.getAsOfDate()); assertNotNull(dispositionAction.getAsOfDate());
assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
// check the search aspect properties // check the search aspect properties
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME)); assertEquals(CutOffAction.NAME,
assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF)); nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF));
} }
}); });
} }
}); });
} }
/** /**
* *
*/ */
public void testMoveRecordFolderBeforeCutOffIntoAFolderWithNoDisposition() throws Exception public void testMoveRecordFolderBeforeCutOffIntoAFolderWithNoDisposition() throws Exception
{ {
doBehaviourDrivenTest(new BehaviourDrivenTest(null, false) doBehaviourDrivenTest(new BehaviourDrivenTest(null, false)
{ {
NodeRef recordFolder; NodeRef recordFolder;
NodeRef destinationRecordCategory; NodeRef destinationRecordCategory;
public void given() public void given()
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
@@ -164,43 +167,44 @@ public class MoveRecordFolderTest extends BaseRMTestCase
NodeRef rcOne = createRecordCategory(false); NodeRef rcOne = createRecordCategory(false);
destinationRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); destinationRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate()); recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate());
// check for the lifecycle aspect // check for the lifecycle aspect
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
// check the disposition action details // check the disposition action details
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder); DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
assertNotNull(dispositionAction); assertNotNull(dispositionAction);
assertNotNull(CutOffAction.NAME, dispositionAction.getName()); assertNotNull(CutOffAction.NAME, dispositionAction.getName());
assertNotNull(dispositionAction.getAsOfDate()); assertNotNull(dispositionAction.getAsOfDate());
assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder)); assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
} }
}); });
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
{ {
public void runImpl() throws Exception public void runImpl() throws Exception
{ {
// check the search aspect properties // check the search aspect properties
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); 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)); assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF));
} }
}); });
} }
public void when() throws Exception public void when() throws Exception
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
{ {
public void runImpl() throws Exception public void runImpl() throws Exception
{ {
// move record folder // move record folder
fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate()); fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate());
} }
}); });
} }
public void then() public void then()
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
@@ -209,29 +213,29 @@ public class MoveRecordFolderTest extends BaseRMTestCase
{ {
// check for the lifecycle aspect // check for the lifecycle aspect
assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
// check the disposition action details // check the disposition action details
assertNull(dispositionService.getNextDispositionAction(recordFolder)); assertNull(dispositionService.getNextDispositionAction(recordFolder));
// check the search aspect properties // check the search aspect properties
assertFalse(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); assertFalse(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
} }
}); });
} }
}); });
} }
/** /**
* *
*/ */
public void testMoveRecordFolderWithRecordsBeforeCutOffRecordLevelDisposition() throws Exception public void testMoveRecordFolderWithRecordsBeforeCutOffRecordLevelDisposition() throws Exception
{ {
doBehaviourDrivenTest(new BehaviourDrivenTest(null, false) doBehaviourDrivenTest(new BehaviourDrivenTest(null, false)
{ {
NodeRef record; NodeRef record;
NodeRef recordFolder; NodeRef recordFolder;
NodeRef destinationRecordCategory; NodeRef destinationRecordCategory;
public void given() public void given()
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
@@ -242,11 +246,11 @@ public class MoveRecordFolderTest extends BaseRMTestCase
destinationRecordCategory = createRecordCategory(true); destinationRecordCategory = createRecordCategory(true);
recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate()); recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate());
record = utils.createRecord(recordFolder, GUID.generate()); record = utils.createRecord(recordFolder, GUID.generate());
// check for the lifecycle aspect // check for the lifecycle aspect
assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
// check the disposition action details // check the disposition action details
assertNull(dispositionService.getNextDispositionAction(recordFolder)); assertNull(dispositionService.getNextDispositionAction(recordFolder));
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
@@ -254,33 +258,34 @@ public class MoveRecordFolderTest extends BaseRMTestCase
assertNotNull(CutOffAction.NAME, dispositionAction.getName()); assertNotNull(CutOffAction.NAME, dispositionAction.getName());
assertNotNull(dispositionAction.getAsOfDate()); assertNotNull(dispositionAction.getAsOfDate());
assertTrue(dispositionService.isNextDispositionActionEligible(record)); assertTrue(dispositionService.isNextDispositionActionEligible(record));
} }
}); });
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
{ {
public void runImpl() throws Exception public void runImpl() throws Exception
{ {
// check the search aspect properties // check the search aspect properties
assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); 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)); assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
} }
}); });
} }
public void when() throws Exception public void when() throws Exception
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
{ {
public void runImpl() throws Exception public void runImpl() throws Exception
{ {
// move record folder // move record folder
fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate()); fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate());
} }
}); });
} }
public void then() public void then()
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
@@ -290,7 +295,7 @@ public class MoveRecordFolderTest extends BaseRMTestCase
// check for the lifecycle aspect // check for the lifecycle aspect
assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
// check the disposition action details // check the disposition action details
assertNull(dispositionService.getNextDispositionAction(recordFolder)); assertNull(dispositionService.getNextDispositionAction(recordFolder));
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record); DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
@@ -298,20 +303,21 @@ public class MoveRecordFolderTest extends BaseRMTestCase
assertNotNull(CutOffAction.NAME, dispositionAction.getName()); assertNotNull(CutOffAction.NAME, dispositionAction.getName());
assertNotNull(dispositionAction.getAsOfDate()); assertNotNull(dispositionAction.getAsOfDate());
assertTrue(dispositionService.isNextDispositionActionEligible(record)); assertTrue(dispositionService.isNextDispositionActionEligible(record));
// check the search aspect properties // check the search aspect properties
assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH));
assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); assertEquals(CutOffAction.NAME,
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
} }
}); });
} }
}); });
} }
/** /**
* Try and move a folder from no disposition schedule to a disposition schedule * Try and move a folder from no disposition schedule to a disposition schedule
* *
* @see https://issues.alfresco.com/jira/browse/RM-1039 * @see https://issues.alfresco.com/jira/browse/RM-1039
*/ */
public void testMoveRecordFolderFromNoDisToDis() throws Exception public void testMoveRecordFolderFromNoDisToDis() throws Exception
@@ -333,7 +339,7 @@ public class MoveRecordFolderTest extends BaseRMTestCase
{ {
assertNotNull(result); assertNotNull(result);
assertNull(dispositionService.getDispositionSchedule(result)); assertNull(dispositionService.getDispositionSchedule(result));
assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING)); assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
} }
}); });
@@ -394,7 +400,6 @@ public class MoveRecordFolderTest extends BaseRMTestCase
}); });
} }
// try and move a cutoff folder // try and move a cutoff folder
public void testMoveCutoffRecordFolder() throws Exception public void testMoveCutoffRecordFolder() throws Exception
{ {
@@ -426,7 +431,7 @@ public class MoveRecordFolderTest extends BaseRMTestCase
return testFolder; return testFolder;
} }
@Override @Override
public void test(NodeRef testFolder) throws Exception public void test(NodeRef testFolder) 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) private NodeRef createRecordCategory(boolean recordLevel)
{ {
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); 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); Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate());