Refactored RecordsManagementService and deprecated the methods. The methods have been moved to RecordService, RecordFolderService and DispostionService. The deprecated method calls in the code have been replaced and the bean definitions have been changed accordingly.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@57893 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-11-13 22:34:29 +00:00
parent 7462cd4fa7
commit 4c01bbbb83
99 changed files with 4038 additions and 3931 deletions

View File

@@ -77,17 +77,17 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
undeclaredRecord = utils.createRecord(rmFolder, "undeclaredRecord.txt");
// Closed folder
closedFolder = rmService.createRecordFolder(rmContainer, "closedFolder");
closedFolder = recordFolderService.createRecordFolder(rmContainer, "closedFolder");
utils.closeFolder(closedFolder);
// Frozen artifacts
recordFolderContainsFrozen = rmService.createRecordFolder(rmContainer, "containsFrozen");
recordFolderContainsFrozen = recordFolderService.createRecordFolder(rmContainer, "containsFrozen");
frozenRecord = utils.createRecord(rmFolder, "frozenRecord.txt");
frozenRecord2 = utils.createRecord(recordFolderContainsFrozen, "frozen2.txt");
frozenRecordFolder = rmService.createRecordFolder(rmContainer, "frozenRecordFolder");
frozenRecordFolder = recordFolderService.createRecordFolder(rmContainer, "frozenRecordFolder");
// MoveTo artifacts
moveToFolder = rmService.createRecordFolder(rmContainer, "moveToFolder");
moveToFolder = recordFolderService.createRecordFolder(rmContainer, "moveToFolder");
moveToCategory = filePlanService.createRecordCategory(rmContainer, "moveToCategory");
}

View File

@@ -40,44 +40,44 @@ import org.alfresco.util.GUID;
/**
* System test for RM-1008
*
*
* @author Roy Wetherall
* @since 2.1
*/
public class RM1008Test extends BaseRMTestCase
{
public class RM1008Test extends BaseRMTestCase
{
private String myUser;
@Override
protected void initServices()
{
super.initServices();
}
@Override
protected boolean isRecordTest()
{
return true;
}
@Override
protected boolean isUserTest()
{
return true;
}
@Override
protected void setupTestUsersImpl(NodeRef filePlan)
{
super.setupTestUsersImpl(filePlan);
myUser = GUID.generate();
createPerson(myUser);
filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, myUser);
}
public void testContainers() throws Exception
{
{
doTestInTransaction(new Test<Void>()
{
@Override
@@ -87,20 +87,20 @@ public class RM1008Test extends BaseRMTestCase
assertNotNull(holdContainer);
NodeRef transferContainer = filePlanService.getTransferContainer(filePlan);
assertNotNull(transferContainer);
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(holdContainer));
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transferContainer));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(holdContainer, RMPermissionModel.FILING));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transferContainer, RMPermissionModel.FILING));
return null;
}
}, rmAdminName);
doTestInTransaction(new Test<Void>()
{
@Override
@@ -110,23 +110,23 @@ public class RM1008Test extends BaseRMTestCase
assertNotNull(holdContainer);
NodeRef transferContainer = filePlanService.getTransferContainer(filePlan);
assertNotNull(transferContainer);
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(holdContainer));
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transferContainer));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(holdContainer, RMPermissionModel.FILING));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transferContainer, RMPermissionModel.FILING));
return null;
}
}, myUser);
}
public void testHold()
{
{
final NodeRef hold = doTestInTransaction(new Test<NodeRef>()
{
@Override
@@ -138,7 +138,7 @@ public class RM1008Test extends BaseRMTestCase
return holds.iterator().next();
}
}, rmAdminName);
doTestInTransaction(new Test<Void>()
{
@Override
@@ -146,82 +146,82 @@ public class RM1008Test extends BaseRMTestCase
{
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(hold, RMPermissionModel.FILING));
return null;
}
}, rmAdminName);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
{
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING));
return null;
}
}, myUser);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
filePlanPermissionService.setPermission(filePlan, myUser, FILING);
return null;
}
}, rmAdminName);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
{
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(hold, RMPermissionModel.FILING));
return null;
}
}, myUser);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
filePlanPermissionService.deletePermission(filePlan, myUser, FILING);
return null;
}
}, rmAdminName);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
{
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING));
return null;
}
}, myUser);
}
public void testTransfer()
{
final NodeRef transferFolder = doTestInTransaction(new Test<NodeRef>()
@@ -235,39 +235,39 @@ public class RM1008Test extends BaseRMTestCase
dsProps.put(PROP_DISPOSITION_AUTHORITY, "test");
dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, "test");
dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, false);
DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(transferCat, dsProps);
DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(transferCat, dsProps);
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, "immediately|0");
adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0");
dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, "transfer");
adParams.put(PROP_DISPOSITION_DESCRIPTION, "test");
adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0");
adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0");
dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
return rmService.createRecordFolder(transferCat, "transferFolder");
return recordFolderService.createRecordFolder(transferCat, "transferFolder");
}
});
final NodeRef transfer = doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run()
{
{
actionService.executeRecordsManagementAction(transferFolder, "cutoff");
actionService.executeRecordsManagementAction(transferFolder, "transfer");
NodeRef transferContainer = filePlanService.getTransferContainer(filePlan);
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(transferContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
return childAssocs.get(0).getChildRef();
return childAssocs.get(0).getChildRef();
}
@Override
public void test(NodeRef result) throws Exception
{
@@ -275,7 +275,7 @@ public class RM1008Test extends BaseRMTestCase
assertEquals(TYPE_TRANSFER, nodeService.getType(result));
}
});
doTestInTransaction(new Test<Void>()
{
@Override
@@ -283,82 +283,82 @@ public class RM1008Test extends BaseRMTestCase
{
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
return null;
}
}, rmAdminName);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
{
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
return null;
}
}, myUser);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
filePlanPermissionService.setPermission(filePlan, myUser, FILING);
return null;
}
}, rmAdminName);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
{
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
return null;
}
}, myUser);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
filePlanPermissionService.deletePermission(filePlan, myUser, FILING);
return null;
}
}, rmAdminName);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
{
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
return null;
}
}, myUser);
}
}

View File

@@ -25,12 +25,12 @@ import org.alfresco.service.cmr.repository.NodeRef;
/**
* Unit test for RM-1027 .. can't copy a closed folder
*
*
* @author Roy Wetherall
* @since 2.1
*/
public class RM1027Test extends BaseRMTestCase
{
public class RM1027Test extends BaseRMTestCase
{
public void testCopyingAClosedFolder() throws Exception
{
final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>()
@@ -39,40 +39,40 @@ public class RM1027Test extends BaseRMTestCase
public NodeRef run()
{
// create a folder and close it
NodeRef recordFolder = rmService.createRecordFolder(rmContainer, "My Closed Record Folder");
NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder");
utils.closeFolder(recordFolder);
assertTrue((Boolean)nodeService.getProperty(recordFolder, PROP_IS_CLOSED));
return recordFolder;
}
});
doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run() throws Exception
{
{
// create a destination for the copy
NodeRef destination = filePlanService.createRecordCategory(filePlan, "Copy Destination");
// try and copy the closed record folder
FileInfo copyInfo = fileFolderService.copy(recordFolder, destination, null);
return copyInfo.getNodeRef();
}
@Override
public void test(NodeRef copy) throws Exception
{
assertNotNull(copy);
assertNotNull(copy);
assertNotNull(nodeService.getProperty(copy, PROP_IDENTIFIER));
assertFalse((Boolean)nodeService.getProperty(copy, PROP_IS_CLOSED));
}
});
});
}
public void testCopyingAFolderWithADispositionSchedule() throws Exception
{
final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>()
@@ -80,38 +80,38 @@ public class RM1027Test extends BaseRMTestCase
@Override
public NodeRef run()
{
// create a folder
NodeRef recordFolder = rmService.createRecordFolder(rmContainer, "My Closed Record Folder");
// create a folder
NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder");
// show that the default disposition schedule has been applied
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
return recordFolder;
}
});
doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run() throws Exception
{
{
// create a destination for the copy
NodeRef destination = filePlanService.createRecordCategory(filePlan, "Copy Destination");
// try and copy the closed record folder
FileInfo copyInfo = fileFolderService.copy(recordFolder, destination, null);
return copyInfo.getNodeRef();
}
@Override
public void test(NodeRef copy) throws Exception
{
assertNotNull(copy);
assertNotNull(copy);
assertNotNull(nodeService.getProperty(copy, PROP_IDENTIFIER));
assertFalse(nodeService.hasAspect(copy, ASPECT_DISPOSITION_LIFECYCLE));
}
});
});
}
}

View File

@@ -36,21 +36,21 @@ import org.alfresco.service.cmr.repository.NodeRef;
/**
* Unit test for RM-1039 ... can't move a folder into a category with a disposition schedule
*
*
* @author Roy Wetherall
* @since 2.1
*/
public class RM1039Test extends BaseRMTestCase
{
public class RM1039Test extends BaseRMTestCase
{
@Override
protected boolean isRecordTest()
{
return true;
}
// try and move a folder from no disposition schedule to a disposition schedule
public void testMoveRecordFolderFromNoDisToDis() throws Exception
{
{
final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>()
{
@Override
@@ -58,11 +58,11 @@ public class RM1039Test extends BaseRMTestCase
{
// create a record category (no disposition schedule)
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
// create a record folder
return rmService.createRecordFolder(recordCategory, "Grace Wetherall");
return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall");
}
@Override
public void test(NodeRef result) throws Exception
{
@@ -71,16 +71,16 @@ public class RM1039Test extends BaseRMTestCase
assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
}
});
final NodeRef record = doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run()
{
// create a record
// create a record
return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef();
}
@Override
public void test(NodeRef result) throws Exception
{
@@ -89,7 +89,7 @@ public class RM1039Test extends BaseRMTestCase
assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
}
});
doTestInTransaction(new Test<NodeRef>()
{
@Override
@@ -98,79 +98,79 @@ public class RM1039Test extends BaseRMTestCase
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("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));
assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
}
});
}
// move from a disposition schedule to another .. both record folder level
// move from a disposition schedule to another .. from record to folder level
// try and move a cutoff folder
public void testMoveCutoffRecordFolder() 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");
return filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
}
});
final NodeRef testFolder = doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run()
{
// create folder
NodeRef testFolder = rmService.createRecordFolder(rmContainer, "Peter Edward Francis");
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);
actionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params);
// cutoff folder
actionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME);
// take a look at the move capability
Capability moveCapability = capabilityService.getCapability("Move");
assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(testFolder, destination));
return testFolder;
return testFolder;
}
});
doTestInTransaction(new FailureTest()
{
{
@Override
public void run() throws Exception
{

View File

@@ -31,63 +31,63 @@ import org.alfresco.util.GUID;
/**
* Records management security service test.
*
*
* @author Roy Wetherall
*/
public class ExtendedSecurityServiceImplTest extends BaseRMTestCase
{
private ExtendedSecurityService extendedSecurityService;
private NodeRef record;
private NodeRef recordToo;
private NodeRef moveRecordCategory;
private NodeRef moveRecordFolder;
@Override
protected boolean isUserTest()
{
return true;
}
@Override
protected void initServices()
{
super.initServices();
extendedSecurityService = (ExtendedSecurityService)applicationContext.getBean("ExtendedSecurityService");
}
@Override
protected void setupTestDataImpl()
{
super.setupTestDataImpl();
record = utils.createRecord(rmFolder, "record.txt");
recordToo = utils.createRecord(rmFolder, "recordToo.txt");
recordToo = utils.createRecord(rmFolder, "recordToo.txt");
moveRecordCategory = filePlanService.createRecordCategory(filePlan, "moveRecordCategory");
moveRecordFolder = rmService.createRecordFolder(moveRecordCategory, "moveRecordFolder");
moveRecordFolder = recordFolderService.createRecordFolder(moveRecordCategory, "moveRecordFolder");
}
private String createTestUser()
{
return doTestInTransaction(new Test<String>()
{
public String run()
{
{
String userName = GUID.generate();
createPerson(userName);
return userName;
}
}, AuthenticationUtil.getSystemUserName());
}
public void testExtendedSecurity()
{
final String monkey = createTestUser();
final String elephant = createTestUser();
final String snake = createTestUser();
doTestInTransaction(new Test<Void>()
{
public Void run()
@@ -96,124 +96,124 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase
assertFalse(extendedSecurityService.hasExtendedSecurity(rmContainer));
assertFalse(extendedSecurityService.hasExtendedSecurity(rmFolder));
assertFalse(extendedSecurityService.hasExtendedSecurity(record));
assertNull(extendedSecurityService.getExtendedReaders(record));
assertNull(extendedSecurityService.getExtendedWriters(record));
Set<String> extendedReaders = new HashSet<String>(2);
extendedReaders.add(monkey);
extendedReaders.add(elephant);
extendedSecurityService.addExtendedSecurity(record, extendedReaders, null);
Map<String, Integer> testMap = new HashMap<String, Integer>(2);
testMap.put(monkey, Integer.valueOf(1));
testMap.put(elephant, Integer.valueOf(1));
checkExtendedReaders(filePlan, testMap);
checkExtendedReaders(rmContainer, testMap);
checkExtendedReaders(rmFolder, testMap);
checkExtendedReaders(record, testMap);
Set<String> extendedReadersToo = new HashSet<String>(2);
extendedReadersToo.add(monkey);
extendedReadersToo.add(snake);
extendedSecurityService.addExtendedSecurity(recordToo, extendedReadersToo, null);
Map<String, Integer> testMapToo = new HashMap<String, Integer>(2);
testMapToo.put(monkey, Integer.valueOf(1));
testMapToo.put(snake, Integer.valueOf(1));
Map<String, Integer> testMapThree = new HashMap<String, Integer>(3);
testMapThree.put(monkey, Integer.valueOf(2));
testMapThree.put(elephant, Integer.valueOf(1));
testMapThree.put(snake, Integer.valueOf(1));
checkExtendedReaders(filePlan, testMapThree);
checkExtendedReaders(rmContainer, testMapThree);
checkExtendedReaders(rmFolder, testMapThree);
checkExtendedReaders(recordToo, testMapToo);
// test remove (with no parent inheritance)
Set<String> removeMap1 = new HashSet<String>(2);
removeMap1.add(elephant);
removeMap1.add(monkey);
extendedSecurityService.removeExtendedSecurity(rmFolder, removeMap1, null, false);
Map<String, Integer> testMapFour = new HashMap<String, Integer>(2);
testMapFour.put(monkey, Integer.valueOf(1));
testMapFour.put(snake, Integer.valueOf(1));
checkExtendedReaders(filePlan, testMapThree);
checkExtendedReaders(rmContainer, testMapThree);
checkExtendedReaders(rmFolder, testMapFour);
checkExtendedReaders(recordToo, testMapToo);
// test remove (apply to parents)
Set<String> removeMap2 = new HashSet<String>(1);
removeMap2.add(snake);
extendedSecurityService.removeExtendedSecurity(recordToo, removeMap2, null, true);
testMapThree.remove(snake);
testMapFour.remove(snake);
testMapToo.remove(snake);
checkExtendedReaders(filePlan, testMapThree);
checkExtendedReaders(rmContainer, testMapThree);
checkExtendedReaders(rmFolder, testMapFour);
checkExtendedReaders(recordToo, testMapToo);
return null;
}
});
}
}
public void testMove()
{
final String monkey = createTestUser();
final String elephant = createTestUser();
doTestInTransaction(new Test<Void>()
{
Map<String, Integer> testMap = new HashMap<String, Integer>(2);
public Void run() throws Exception
{
testMap.put(monkey, Integer.valueOf(1));
testMap.put(elephant, Integer.valueOf(1));
testMap.put(elephant, Integer.valueOf(1));
assertFalse(extendedSecurityService.hasExtendedSecurity(filePlan));
assertFalse(extendedSecurityService.hasExtendedSecurity(rmContainer));
assertFalse(extendedSecurityService.hasExtendedSecurity(rmFolder));
assertFalse(extendedSecurityService.hasExtendedSecurity(record));
assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordCategory));
assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordFolder));
assertNull(extendedSecurityService.getExtendedReaders(record));
Set<String> extendedReaders = new HashSet<String>(2);
extendedReaders.add(monkey);
extendedReaders.add(elephant);
extendedSecurityService.addExtendedSecurity(record, extendedReaders, null);
checkExtendedReaders(filePlan, testMap);
checkExtendedReaders(rmContainer, testMap);
checkExtendedReaders(rmFolder, testMap);
checkExtendedReaders(record, testMap);
assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordCategory));
assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordFolder));
fileFolderService.move(record, moveRecordFolder, "movedRecord");
return null;
}
@Override
public void test(Void result) throws Exception
{
@@ -224,26 +224,26 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase
checkExtendedReaders(moveRecordFolder, testMap);
checkExtendedReaders(record, testMap);
}
});
});
}
@SuppressWarnings("unchecked")
private void checkExtendedReaders(NodeRef nodeRef, Map<String, Integer> testMap)
{
assertTrue(extendedSecurityService.hasExtendedSecurity(nodeRef));
Map<String, Integer> readersMap = (Map<String,Integer>)nodeService.getProperty(nodeRef, PROP_READERS);
assertNotNull(readersMap);
assertEquals(testMap.size(), readersMap.size());
for (Map.Entry<String, Integer> entry: testMap.entrySet())
{
assertTrue(readersMap.containsKey(entry.getKey()));
assertEquals(entry.getKey(), entry.getValue(), readersMap.get(entry.getKey()));
}
Set<String> readers = extendedSecurityService.getExtendedReaders(nodeRef);
assertNotNull(readers);
assertEquals(testMap.size(), readers.size());

View File

@@ -28,7 +28,7 @@ import org.springframework.extensions.webscripts.GUID;
/**
* File plan permission service unit test
*
*
* @author Roy Wetherall
* @since 2.1
*/
@@ -42,16 +42,16 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
{
return true;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest()
*/
@Override
protected boolean isRecordTest()
{
return true;
return true;
}
/**
* Helper to create test user
*/
@@ -69,7 +69,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
}
}, AuthenticationUtil.getSystemUserName());
}
/**
* Helper to set permission
*/
@@ -83,9 +83,9 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
filePlanPermissionService.setPermission(nodeRef, userName, permission);
return null;
}
});
});
}
/**
* Helper to delete permission
*/
@@ -99,17 +99,17 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
filePlanPermissionService.deletePermission(nodeRef, userName, permission);
return null;
}
});
});
}
/**
* test set/delete permissions on file plan
*/
public void testSetDeletePermissionFilePlan() throws Exception
{
String userName = createTestUser();
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -118,10 +118,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record folder file
AccessStatus.DENIED, // record read
AccessStatus.DENIED); // record file
setPermission(filePlan, userName, RMPermissionModel.FILING);
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.ALLOWED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -130,10 +130,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.ALLOWED, // record folder file
AccessStatus.ALLOWED, // record read
AccessStatus.ALLOWED); // record file
deletePermission(filePlan, userName, RMPermissionModel.FILING);
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -142,12 +142,12 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record folder file
AccessStatus.DENIED, // record read
AccessStatus.DENIED); // record file
//what happens if we try and remove READ for a normal user on the file plan ???
deletePermission(filePlan, userName, RMPermissionModel.READ_RECORDS);
// nothing .. user still has read on file plan .. only removing the user from all roles will remove read on file plan
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -157,15 +157,15 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record read
AccessStatus.DENIED); // record file
}
/**
* Test set/delete permission on record categorty
*/
public void testSetDeletePermissionRecordCategory() throws Exception
{
String userName = createTestUser();
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -174,10 +174,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record folder file
AccessStatus.DENIED, // record read
AccessStatus.DENIED); // record file
setPermission(rmContainer, userName, RMPermissionModel.FILING);
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -186,10 +186,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.ALLOWED, // record folder file
AccessStatus.ALLOWED, // record read
AccessStatus.ALLOWED); // record file
deletePermission(rmContainer, userName, RMPermissionModel.FILING);
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -199,15 +199,15 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record read
AccessStatus.DENIED); // record file
}
/**
* Test set/delete permission on record folder
*/
public void testSetDeletePermissionRecordFolder() throws Exception
{
String userName = createTestUser();
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -216,10 +216,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record folder file
AccessStatus.DENIED, // record read
AccessStatus.DENIED); // record file
setPermission(rmFolder, userName, RMPermissionModel.FILING);
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -228,10 +228,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.ALLOWED, // record folder file
AccessStatus.ALLOWED, // record read
AccessStatus.ALLOWED); // record file
deletePermission(rmFolder, userName, RMPermissionModel.FILING);
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -241,15 +241,15 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record read
AccessStatus.DENIED); // record file
}
/**
* Test set/delete permission on record
*/
public void testSetDeletePermissionRecord() throws Exception
{
String userName = createTestUser();
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -258,10 +258,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record folder file
AccessStatus.DENIED, // record read
AccessStatus.DENIED); // record file
setPermission(recordOne, userName, RMPermissionModel.FILING);
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -270,10 +270,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record folder file
AccessStatus.ALLOWED, // record read
AccessStatus.ALLOWED); // record file
deletePermission(recordOne, userName, RMPermissionModel.FILING);
assertPermissions(userName,
assertPermissions(userName,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -283,23 +283,23 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
AccessStatus.DENIED, // record read
AccessStatus.DENIED); // record file
}
public void testMoveRecord() throws Exception
{
String userOne = createTestUser();
String userTwo = createTestUser();
String userThree = createTestUser();
final NodeRef otherFolder = doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run()
{
return rmService.createRecordFolder(rmContainer, "otherFolder");
return recordFolderService.createRecordFolder(rmContainer, "otherFolder");
}
});
assertPermissions(userOne,
assertPermissions(userOne,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -318,7 +318,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
}, userOne);
assertPermissions(userTwo,
assertPermissions(userTwo,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -337,7 +337,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
}, userTwo);
assertPermissions(userThree,
assertPermissions(userThree,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.DENIED, // category read
@@ -356,12 +356,12 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
}, userThree);
setPermission(rmFolder, userOne, RMPermissionModel.FILING);
setPermission(otherFolder, userTwo, RMPermissionModel.FILING);
setPermission(recordOne, userThree, RMPermissionModel.FILING);
assertPermissions(userOne,
assertPermissions(userOne,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -380,7 +380,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
}, userOne);
assertPermissions(userTwo,
assertPermissions(userTwo,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -399,7 +399,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
}, userTwo);
assertPermissions(userThree,
assertPermissions(userThree,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -418,7 +418,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
}, userThree);
// move the record!
doTestInTransaction(new Test<Void>()
{
@@ -429,8 +429,8 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
});
assertPermissions(userOne,
assertPermissions(userOne,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -449,7 +449,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
}, userOne);
assertPermissions(userTwo,
assertPermissions(userTwo,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -468,7 +468,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
}, userTwo);
assertPermissions(userThree,
assertPermissions(userThree,
AccessStatus.ALLOWED, // fileplan read
AccessStatus.DENIED, // fileplan file
AccessStatus.ALLOWED, // category read
@@ -487,38 +487,38 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase
return null;
}
}, userThree);
}
/**
* Helper to assert permissions for passed user
*/
private void assertPermissions(final String userName, final AccessStatus ... accessStatus)
{
assertEquals(8, accessStatus.length);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
assertEquals("Everyone who has a role has read permissions on the file plan",
assertEquals("Everyone who has a role has read permissions on the file plan",
accessStatus[0], permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS));
assertEquals(accessStatus[1], permissionService.hasPermission(filePlan, RMPermissionModel.FILING));
assertEquals(accessStatus[2], permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS));
assertEquals(accessStatus[3], permissionService.hasPermission(rmContainer, RMPermissionModel.FILING));
assertEquals(accessStatus[4], permissionService.hasPermission(rmFolder, RMPermissionModel.READ_RECORDS));
assertEquals(accessStatus[5], permissionService.hasPermission(rmFolder, RMPermissionModel.FILING));
assertEquals(accessStatus[6], permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS));
assertEquals(accessStatus[7], permissionService.hasPermission(recordOne, RMPermissionModel.FILING));
return null;
}
}, userName);
}
}

View File

@@ -30,21 +30,21 @@ import org.alfresco.util.GUID;
/**
* File plan service unit test
*
*
* @author Roy Wetherall
* @since 2.1
*/
public class FilePlanServiceImplTest extends BaseRMTestCase
{
/**
* Pull in collaboration test data
/**
* Pull in collaboration test data
*/
@Override
protected boolean isCollaborationSiteTest()
{
return true;
}
/**
* {@link FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef)}
*/
@@ -53,14 +53,14 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
doTestInTransaction(new VoidTest()
{
public void runImpl() throws Exception
{
{
assertTrue(filePlanService.isFilePlan(filePlan));
assertFalse(filePlanService.isFilePlan(rmContainer));
assertFalse(filePlanService.isFilePlan(dmDocument));
}
});
});
}
/**
* {@link FilePlanService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef)}
*/
@@ -69,15 +69,15 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
doTestInTransaction(new VoidTest()
{
public void runImpl() throws Exception
{
{
assertEquals(filePlan, filePlanService.getFilePlan(filePlan));
assertEquals(filePlan, filePlanService.getFilePlan(rmContainer));
assertEquals(filePlan, filePlanService.getFilePlan(rmFolder));
assertNull(filePlanService.getFilePlan(dmDocument));
}
});
});
}
/**
* {@link FilePlanService#getFilePlanBySiteId(String)}
*/
@@ -86,18 +86,18 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
doTestInTransaction(new VoidTest()
{
public void runImpl() throws Exception
{
{
assertEquals(filePlan, filePlanService.getFilePlanBySiteId(siteId));
assertNull(filePlanService.getFilePlanBySiteId("rubbish"));
String siteId = GUID.generate();
siteService.createSite("anything", siteId, "title", "descrition", SiteVisibility.PUBLIC);
assertNull(filePlanService.getFilePlanBySiteId(siteId));
}
});
});
}
/**
* @see FilePlanService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef)
*/
@@ -111,12 +111,12 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
assertTrue("The rm root container should be a rm component", filePlanService.isFilePlanComponent(filePlan));
assertTrue("The rm container should be a rm component", filePlanService.isFilePlanComponent(rmContainer));
assertTrue("The rm folder should be a rm component", filePlanService.isFilePlanComponent(rmFolder));
return null;
}
});
}
/**
* @see FilePlanService#getFilePlanComponentKind(NodeRef)
*/
@@ -129,20 +129,20 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
{
return utils.createRecord(rmFolder, "testRecord.txt");
}
@Override
public void test(NodeRef result) throws Exception
{
assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan));
assertEquals(FilePlanComponentKind.RECORD_CATEGORY, filePlanService.getFilePlanComponentKind(rmContainer));
assertEquals(FilePlanComponentKind.RECORD_FOLDER, filePlanService.getFilePlanComponentKind(rmFolder));
assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result));
// TODO HOLD and TRANSFER
assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result));
// TODO HOLD and TRANSFER
assertNull(filePlanService.getFilePlanComponentKind(folder));
}
});
});
}
/**
* @see FilePlanService#isRecordCategory(NodeRef)
*/
@@ -156,12 +156,12 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
assertFalse("This should not be a record category.", filePlanService.isRecordCategory(filePlan));
assertTrue("This is a record category.", filePlanService.isRecordCategory(rmContainer));
assertFalse("This should not be a record category.", filePlanService.isRecordCategory(rmFolder));
return null;
}
});
}
/**
* @see FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String)
* @see FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String, org.alfresco.service.namespace.QName)
@@ -185,7 +185,7 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN);
}
});
// Create specific type of root
doTestInTransaction(new Test<NodeRef>()
{
@@ -203,43 +203,43 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN);
}
});
// Failure: creating root in existing hierarchy
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
filePlanService.createFilePlan(rmContainer, GUID.generate());
filePlanService.createFilePlan(rmContainer, GUID.generate());
}
});
// Failure: type no extended from root container
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER);
filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER);
}
});
}
/**
* A basic test of a records management container
*
*
* @param nodeRef node reference
* @param name name of the container
* @param type the type of container
* @param type the type of container
*/
private void basicRMContainerCheck(NodeRef nodeRef, String name, QName type)
{
// Check the basic details
assertEquals(name, nodeService.getProperty(nodeRef, PROP_NAME));
assertNotNull("RM id has not been set", nodeService.getProperty(nodeRef, PROP_IDENTIFIER));
assertEquals(type, nodeService.getType(nodeRef));
assertEquals(type, nodeService.getType(nodeRef));
}
/**
* @see FilePlanService#createRecordCategory(NodeRef, String)
* @see FilePlanService#createRecordCategory(NodeRef, String, org.alfresco.service.namespace.QName)
@@ -263,7 +263,7 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY);
}
});
// Create container (in container)
doTestInTransaction(new Test<NodeRef>()
{
@@ -281,7 +281,7 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY);
}
});
// TODO need a custom type of container!
// Create container of a given type
// doTestInTransaction(new Test<NodeRef>()
@@ -300,28 +300,28 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
// basicRMContainerCheck(result, getString("id"), TYPE_RECORD_SERIES);
// }
// });
// Fail Test: parent is not a container
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
filePlanService.createRecordCategory(folder, GUID.generate());
filePlanService.createRecordCategory(folder, GUID.generate());
}
});
// Fail Test: type is not a sub-type of rm:recordsManagementContainer
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER);
filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER);
}
});
}
/**
* @see FilePlanService#getAllContained(NodeRef)
* @see FilePlanService#getAllContained(NodeRef, boolean)
@@ -336,43 +336,43 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
{
// Add to the test data
NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries");
NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer");
// Put in model
setNodeRef("series", series);
setNodeRef("seriesChildFolder", seriesChildFolder);
setNodeRef("seriesChildContainer", seriesChildContainer);
return null;
}
@Override
public void test(Void result) throws Exception
{
{
List<NodeRef> nodes = filePlanService.getAllContained(rmContainer);
assertNotNull(nodes);
assertEquals(2, nodes.size());
assertEquals(2, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
assertTrue(nodes.contains(rmFolder));
nodes = filePlanService.getAllContained(rmContainer, false);
assertNotNull(nodes);
assertEquals(2, nodes.size());
assertEquals(2, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
assertTrue(nodes.contains(rmFolder));
nodes = filePlanService.getAllContained(rmContainer, true);
assertNotNull(nodes);
assertEquals(4, nodes.size());
assertEquals(4, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
assertTrue(nodes.contains(rmFolder));
assertTrue(nodes.contains(rmFolder));
assertTrue(nodes.contains(getNodeRef("seriesChildFolder")));
assertTrue(nodes.contains(getNodeRef("seriesChildContainer")));
}
});
// Failure: call on record folder
doTestInTransaction(new FailureTest()
{
@@ -381,9 +381,9 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
{
filePlanService.getAllContained(rmFolder);
}
});
});
}
/**
* @see FilePlanService#getContainedRecordCategories(NodeRef)
* @see FilePlanService#getContainedRecordCategories(NodeRef, boolean)
@@ -398,38 +398,38 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
{
// Add to the test data
NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries");
NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer");
// Put in model
setNodeRef("series", series);
setNodeRef("seriesChildFolder", seriesChildFolder);
setNodeRef("seriesChildContainer", seriesChildContainer);
return null;
}
@Override
public void test(Void result) throws Exception
{
{
List<NodeRef> nodes = filePlanService.getContainedRecordCategories(rmContainer);
assertNotNull(nodes);
assertEquals(1, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
assertEquals(1, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
nodes = filePlanService.getContainedRecordCategories(rmContainer, false);
assertNotNull(nodes);
assertEquals(1, nodes.size());
assertEquals(1, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
nodes = filePlanService.getContainedRecordCategories(rmContainer, true);
assertNotNull(nodes);
assertEquals(2, nodes.size());
assertEquals(2, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
assertTrue(nodes.contains(getNodeRef("seriesChildContainer")));
}
});
// Failure: call on record folder
doTestInTransaction(new FailureTest()
{
@@ -438,9 +438,9 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
{
filePlanService.getContainedRecordCategories(rmFolder);
}
});
});
}
/**
* @see FilePlanService#getContainedRecordFolders(NodeRef)
* @see FilePlanService#getContainedRecordFolders(NodeRef, boolean)
@@ -455,38 +455,38 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
{
// Add to the test data
NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries");
NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer");
// Put in model
setNodeRef("series", series);
setNodeRef("seriesChildFolder", seriesChildFolder);
setNodeRef("seriesChildContainer", seriesChildContainer);
return null;
}
@Override
public void test(Void result) throws Exception
{
{
List<NodeRef> nodes = filePlanService.getContainedRecordFolders(rmContainer);
assertNotNull(nodes);
assertEquals(1, nodes.size());
assertTrue(nodes.contains(rmFolder));
assertEquals(1, nodes.size());
assertTrue(nodes.contains(rmFolder));
nodes = filePlanService.getContainedRecordFolders(rmContainer, false);
assertNotNull(nodes);
assertEquals(1, nodes.size());
assertTrue(nodes.contains(rmFolder));
assertEquals(1, nodes.size());
assertTrue(nodes.contains(rmFolder));
nodes = filePlanService.getContainedRecordFolders(rmContainer, true);
assertNotNull(nodes);
assertEquals(2, nodes.size());
assertTrue(nodes.contains(rmFolder));
assertEquals(2, nodes.size());
assertTrue(nodes.contains(rmFolder));
assertTrue(nodes.contains(getNodeRef("seriesChildFolder")));
}
});
// Failure: call on record folder
doTestInTransaction(new FailureTest()
{
@@ -495,11 +495,11 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
{
filePlanService.getContainedRecordFolders(rmFolder);
}
});
});
}
/**
* Test to create a simple multi-hierarchy record taxonomy
* Test to create a simple multi-hierarchy record taxonomy
*/
public void testCreateSimpleHierarchy()
{
@@ -509,15 +509,15 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
public Void run()
{
// Create 3 level hierarchy
NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1"));
NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1"));
assertNotNull("Unable to create container", levelOne);
NodeRef levelTwo = setNodeRef("container2", filePlanService.createRecordCategory(levelOne, "container2"));
assertNotNull("Unable to create container", levelTwo);
NodeRef levelThree = setNodeRef("container3", filePlanService.createRecordCategory(levelTwo, "container3"));
assertNotNull("Unable to create container", levelThree);
NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", rmService.createRecordFolder(levelThree, "recordFolder3"));
NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", recordFolderService.createRecordFolder(levelThree, "recordFolder3"));
assertNotNull("Unable to create record folder", levelThreeRecordFolder);
return null;
}
@@ -529,9 +529,9 @@ public class FilePlanServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(getNodeRef("container2"), "container2", TYPE_RECORD_CATEGORY);
basicRMContainerCheck(getNodeRef("container3"), "container3", TYPE_RECORD_CATEGORY);
basicRMContainerCheck(getNodeRef("recordFolder3"), "recordFolder3", TYPE_RECORD_FOLDER);
// TODO need to check that the parents and children can be retrieved correctly
}
});
});
}
}

View File

@@ -18,10 +18,12 @@
*/
package org.alfresco.module.org_alfresco_module_rm.test.service;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -30,17 +32,16 @@ import org.alfresco.util.GUID;
/**
* Records management service test.
*
*
* @author Roy Wetherall
*/
public class RecordsManagementServiceImplTest extends BaseRMTestCase
{
{
/********** RM Component methods **********/
/**
* @see RecordsManagementService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef)
* @see FilePlanService#isFilePlanComponent(NodeRef)
*/
@SuppressWarnings("deprecation")
public void testIsFilePlanComponent() throws Exception
{
doTestInTransaction(new Test<NodeRef>()
@@ -48,19 +49,18 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
@Override
public NodeRef run()
{
assertTrue("The rm root container should be a rm component", rmService.isFilePlanComponent(filePlan));
assertTrue("The rm container should be a rm component", rmService.isFilePlanComponent(rmContainer));
assertTrue("The rm folder should be a rm component", rmService.isFilePlanComponent(rmFolder));
assertTrue("The rm root container should be a rm component", filePlanService.isFilePlanComponent(filePlan));
assertTrue("The rm container should be a rm component", filePlanService.isFilePlanComponent(rmContainer));
assertTrue("The rm folder should be a rm component", filePlanService.isFilePlanComponent(rmFolder));
return null;
}
});
}
/**
* @see RecordsManagementService#getFilePlanComponentKind(NodeRef)
* @see FilePlanService#getFilePlanComponentKind(NodeRef)
*/
@SuppressWarnings("deprecation")
public void testGetFilePlanComponentKind() throws Exception
{
doTestInTransaction(new Test<NodeRef>()
@@ -70,24 +70,23 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
{
return utils.createRecord(rmFolder, "testRecord.txt");
}
@Override
public void test(NodeRef result) throws Exception
{
assertEquals(FilePlanComponentKind.FILE_PLAN, rmService.getFilePlanComponentKind(filePlan));
assertEquals(FilePlanComponentKind.RECORD_CATEGORY, rmService.getFilePlanComponentKind(rmContainer));
assertEquals(FilePlanComponentKind.RECORD_FOLDER, rmService.getFilePlanComponentKind(rmFolder));
assertEquals(FilePlanComponentKind.RECORD, rmService.getFilePlanComponentKind(result));
// TODO HOLD and TRANSFER
assertNull(rmService.getFilePlanComponentKind(folder));
assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan));
assertEquals(FilePlanComponentKind.RECORD_CATEGORY, filePlanService.getFilePlanComponentKind(rmContainer));
assertEquals(FilePlanComponentKind.RECORD_FOLDER, filePlanService.getFilePlanComponentKind(rmFolder));
assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result));
// TODO HOLD and TRANSFER
assertNull(filePlanService.getFilePlanComponentKind(folder));
}
});
});
}
/**
* @see RecordsManagementService#isFilePlan(NodeRef)
* @see FilePlanService#isFilePlan(NodeRef)
*/
@SuppressWarnings("deprecation")
public void testIsFilePlan() throws Exception
{
doTestInTransaction(new Test<NodeRef>()
@@ -95,19 +94,18 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
@Override
public NodeRef run()
{
assertTrue("This is a records management root", rmService.isFilePlan(filePlan));
assertFalse("This should not be a records management root", rmService.isFilePlan(rmContainer));
assertFalse("This should not be a records management root", rmService.isFilePlan(rmFolder));
assertTrue("This is a records management root", filePlanService.isFilePlan(filePlan));
assertFalse("This should not be a records management root", filePlanService.isFilePlan(rmContainer));
assertFalse("This should not be a records management root", filePlanService.isFilePlan(rmFolder));
return null;
}
});
}
/**
* @see RecordsManagementService#isRecordCategory(NodeRef)
* @see FilePlanService#isRecordCategory(NodeRef)
*/
@SuppressWarnings("deprecation")
public void testIsRecordCategory() throws Exception
{
doTestInTransaction(new Test<NodeRef>()
@@ -115,17 +113,17 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
@Override
public NodeRef run()
{
assertFalse("This should not be a record category.", rmService.isRecordCategory(filePlan));
assertTrue("This is a record category.", rmService.isRecordCategory(rmContainer));
assertFalse("This should not be a record category.", rmService.isRecordCategory(rmFolder));
assertFalse("This should not be a record category.", filePlanService.isRecordCategory(filePlan));
assertTrue("This is a record category.", filePlanService.isRecordCategory(rmContainer));
assertFalse("This should not be a record category.", filePlanService.isRecordCategory(rmFolder));
return null;
}
});
}
/**
* @see RecordsManagementService#isRecordFolder(NodeRef)
* @see RecordFolderService#isRecordFolder(NodeRef)
*/
public void testIsRecordFolder() throws Exception
{
@@ -134,63 +132,57 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
@Override
public NodeRef run()
{
assertFalse("This should not be a record folder", rmService.isRecordFolder(filePlan));
assertFalse("This should not be a record folder", rmService.isRecordFolder(rmContainer));
assertTrue("This should be a record folder", rmService.isRecordFolder(rmFolder));
assertFalse("This should not be a record folder", recordFolderService.isRecordFolder(filePlan));
assertFalse("This should not be a record folder", recordFolderService.isRecordFolder(rmContainer));
assertTrue("This should be a record folder", recordFolderService.isRecordFolder(rmFolder));
return null;
}
});
}
/**
* @see RecordsManagementService#getRecordsManagementRoot()
*/
public void testGetRecordsManagementRoot() throws Exception
{
doTestInTransaction(new Test<NodeRef>()
{
@SuppressWarnings("deprecation")
@Override
public NodeRef run()
{
assertEquals(filePlan, rmService.getFilePlan(filePlan));
assertEquals(filePlan, rmService.getFilePlan(rmContainer));
assertEquals(filePlan, rmService.getFilePlan(rmFolder));
assertEquals(filePlan, filePlanService.getFilePlan(filePlan));
assertEquals(filePlan, filePlanService.getFilePlan(rmContainer));
assertEquals(filePlan, filePlanService.getFilePlan(rmFolder));
return null;
}
});
}
/********** Record Management Root methods **********/
/**
* @see RecordsManagementService#getFilePlans()
* @see FilePlanService#getFilePlans()
*/
public void testGetRecordsManagementRoots() throws Exception
{
doTestInTransaction(new Test<NodeRef>()
{
@SuppressWarnings("deprecation")
@Override
public NodeRef run()
{
List<NodeRef> roots = rmService.getFilePlans();
List<NodeRef> roots = new ArrayList<NodeRef>(filePlanService.getFilePlans());
assertNotNull(roots);
assertTrue(roots.size() != 0);
assertTrue(roots.contains(filePlan));
assertTrue(roots.contains(filePlan));
return null;
}
});
});
}
/**
* @see RecordsManagementService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String)
* @see RecordsManagementService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String, org.alfresco.service.namespace.QName)
* @see FilePlanService#createFilePlan(NodeRef, String)
* @see FilePlanService#createFilePlan(NodeRef, String, QName)
*/
@SuppressWarnings("deprecation")
public void testCreateFilePlan() throws Exception
{
// Create default type of root
@@ -200,7 +192,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
public NodeRef run()
{
String id = setString("id", GUID.generate());
return rmService.createFilePlan(folder, id);
return filePlanService.createFilePlan(folder, id);
}
@Override
@@ -210,7 +202,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN);
}
});
// Create specific type of root
doTestInTransaction(new Test<NodeRef>()
{
@@ -218,7 +210,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
public NodeRef run()
{
String id = setString("id", GUID.generate());
return rmService.createFilePlan(folder, id, TYPE_FILE_PLAN);
return filePlanService.createFilePlan(folder, id, TYPE_FILE_PLAN);
}
@Override
@@ -228,35 +220,34 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN);
}
});
// Failure: creating root in existing hierarchy
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
rmService.createFilePlan(rmContainer, GUID.generate());
filePlanService.createFilePlan(rmContainer, GUID.generate());
}
});
// Failure: type no extended from root container
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
rmService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER);
filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER);
}
});
}
/********** Records Management Container methods **********/
/**
* @see RecordsManagementService#createRecordCategory(NodeRef, String)
* @see RecordsManagementService#createRecordCategory(NodeRef, String, org.alfresco.service.namespace.QName)
* @see FilePlanService#createRecordCategory(NodeRef, String)
* @see FilePlanService#createFilePlan(NodeRef, String, QName)
*/
@SuppressWarnings("deprecation")
public void testCreateRecordCategory() throws Exception
{
// Create container (in root)
@@ -266,7 +257,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
public NodeRef run()
{
String id = setString("id", GUID.generate());
return rmService.createRecordCategory(filePlan, id);
return filePlanService.createRecordCategory(filePlan, id);
}
@Override
@@ -276,7 +267,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY);
}
});
// Create container (in container)
doTestInTransaction(new Test<NodeRef>()
{
@@ -284,7 +275,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
public NodeRef run()
{
String id = setString("id", GUID.generate());
return rmService.createRecordCategory(rmContainer, id);
return filePlanService.createRecordCategory(rmContainer, id);
}
@Override
@@ -294,7 +285,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY);
}
});
// TODO need a custom type of container!
// Create container of a given type
// doTestInTransaction(new Test<NodeRef>()
@@ -303,7 +294,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
// public NodeRef run()
// {
// String id = setString("id", GUID.generate());
// return rmService.createRecordCategory(filePlan, id, TYPE_RECORD_SERIES);
// return filePlanService.createRecordCategory(filePlan, id, TYPE_RECORD_SERIES);
// }
//
// @Override
@@ -313,33 +304,32 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
// basicRMContainerCheck(result, getString("id"), TYPE_RECORD_SERIES);
// }
// });
// Fail Test: parent is not a container
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
rmService.createRecordCategory(folder, GUID.generate());
filePlanService.createRecordCategory(folder, GUID.generate());
}
});
// Fail Test: type is not a sub-type of rm:recordsManagementContainer
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
rmService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER);
filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER);
}
});
}
/**
* @see RecordsManagementService#getAllContained(NodeRef)
* @see RecordsManagementService#getAllContained(NodeRef, boolean)
* @see FilePlanService#getAllContained(NodeRef)
* @see FilePlanService#getAllContained(NodeRef, boolean)
*/
@SuppressWarnings("deprecation")
public void testGetAllContained() throws Exception
{
// Get all contained test
@@ -349,60 +339,59 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
public Void run()
{
// Add to the test data
NodeRef series = rmService.createRecordCategory(rmContainer, "rmSeries");
NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildContainer = rmService.createRecordCategory(series, "childContainer");
NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries");
NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer");
// Put in model
setNodeRef("series", series);
setNodeRef("seriesChildFolder", seriesChildFolder);
setNodeRef("seriesChildContainer", seriesChildContainer);
return null;
}
@Override
public void test(Void result) throws Exception
{
List<NodeRef> nodes = rmService.getAllContained(rmContainer);
{
List<NodeRef> nodes = filePlanService.getAllContained(rmContainer);
assertNotNull(nodes);
assertEquals(2, nodes.size());
assertEquals(2, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
assertTrue(nodes.contains(rmFolder));
nodes = rmService.getAllContained(rmContainer, false);
nodes = filePlanService.getAllContained(rmContainer, false);
assertNotNull(nodes);
assertEquals(2, nodes.size());
assertEquals(2, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
assertTrue(nodes.contains(rmFolder));
nodes = rmService.getAllContained(rmContainer, true);
nodes = filePlanService.getAllContained(rmContainer, true);
assertNotNull(nodes);
assertEquals(4, nodes.size());
assertEquals(4, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
assertTrue(nodes.contains(rmFolder));
assertTrue(nodes.contains(rmFolder));
assertTrue(nodes.contains(getNodeRef("seriesChildFolder")));
assertTrue(nodes.contains(getNodeRef("seriesChildContainer")));
}
});
// Failure: call on record folder
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
rmService.getAllContained(rmFolder);
filePlanService.getAllContained(rmFolder);
}
});
});
}
/**
* @see RecordsManagementService#getContainedRecordCategories(NodeRef)
* @see RecordsManagementService#getContainedRecordCategories(NodeRef, boolean)
* @see FilePlanService#getContainedRecordCategories(NodeRef)
* @see FilePlanService#getContainedRecordCategories(NodeRef, boolean)
*/
@SuppressWarnings("deprecation")
public void testGetContainedRecordCategories() throws Exception
{
// Test getting all contained containers
@@ -412,55 +401,54 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
public Void run()
{
// Add to the test data
NodeRef series = rmService.createRecordCategory(rmContainer, "rmSeries");
NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildContainer = rmService.createRecordCategory(series, "childContainer");
NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries");
NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer");
// Put in model
setNodeRef("series", series);
setNodeRef("seriesChildFolder", seriesChildFolder);
setNodeRef("seriesChildContainer", seriesChildContainer);
return null;
}
@Override
public void test(Void result) throws Exception
{
List<NodeRef> nodes = rmService.getContainedRecordCategories(rmContainer);
{
List<NodeRef> nodes = filePlanService.getContainedRecordCategories(rmContainer);
assertNotNull(nodes);
assertEquals(1, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
nodes = rmService.getContainedRecordCategories(rmContainer, false);
assertNotNull(nodes);
assertEquals(1, nodes.size());
assertEquals(1, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
nodes = rmService.getContainedRecordCategories(rmContainer, true);
nodes = filePlanService.getContainedRecordCategories(rmContainer, false);
assertNotNull(nodes);
assertEquals(2, nodes.size());
assertEquals(1, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
nodes = filePlanService.getContainedRecordCategories(rmContainer, true);
assertNotNull(nodes);
assertEquals(2, nodes.size());
assertTrue(nodes.contains(getNodeRef("series")));
assertTrue(nodes.contains(getNodeRef("seriesChildContainer")));
}
});
// Failure: call on record folder
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
rmService.getContainedRecordCategories(rmFolder);
filePlanService.getContainedRecordCategories(rmFolder);
}
});
});
}
/**
* @see RecordsManagementService#getContainedRecordFolders(NodeRef)
* @see RecordsManagementService#getContainedRecordFolders(NodeRef, boolean)
* @see FilePlanService#getContainedRecordFolders(NodeRef)
* @see FilePlanService#getContainedRecordFolders(NodeRef, boolean)
*/
@SuppressWarnings("deprecation")
public void testGetContainedRecordFolders() throws Exception
{
// Test getting all contained record folders
@@ -470,72 +458,72 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
public Void run()
{
// Add to the test data
NodeRef series = rmService.createRecordCategory(rmContainer, "rmSeries");
NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildContainer = rmService.createRecordCategory(series, "childContainer");
NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries");
NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder");
NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer");
// Put in model
setNodeRef("series", series);
setNodeRef("seriesChildFolder", seriesChildFolder);
setNodeRef("seriesChildContainer", seriesChildContainer);
return null;
}
@Override
public void test(Void result) throws Exception
{
List<NodeRef> nodes = rmService.getContainedRecordFolders(rmContainer);
{
List<NodeRef> nodes = filePlanService.getContainedRecordFolders(rmContainer);
assertNotNull(nodes);
assertEquals(1, nodes.size());
assertTrue(nodes.contains(rmFolder));
nodes = rmService.getContainedRecordFolders(rmContainer, false);
assertEquals(1, nodes.size());
assertTrue(nodes.contains(rmFolder));
nodes = filePlanService.getContainedRecordFolders(rmContainer, false);
assertNotNull(nodes);
assertEquals(1, nodes.size());
assertTrue(nodes.contains(rmFolder));
nodes = rmService.getContainedRecordFolders(rmContainer, true);
assertEquals(1, nodes.size());
assertTrue(nodes.contains(rmFolder));
nodes = filePlanService.getContainedRecordFolders(rmContainer, true);
assertNotNull(nodes);
assertEquals(2, nodes.size());
assertTrue(nodes.contains(rmFolder));
assertEquals(2, nodes.size());
assertTrue(nodes.contains(rmFolder));
assertTrue(nodes.contains(getNodeRef("seriesChildFolder")));
}
});
// Failure: call on record folder
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
rmService.getContainedRecordFolders(rmFolder);
filePlanService.getContainedRecordFolders(rmFolder);
}
});
});
}
/********** Record Folder methods **********/
/********** Record Folder methods **********/
// TODO void testIsRecordFolderDeclared()
// TODO void testIsRecordFolderClosed()
// TODO void testGetRecords()
/**
* @see RecordsManagementService#createRecordFolder(NodeRef, String)
* @see RecordsManagementService#createRecordFolder(NodeRef, String, QName)
* @see RecordFolderService#createRecordFolder(NodeRef, String)
* @see RecordFolderService#createRecordFolder(NodeRef, String, QName)
*/
public void testCreateRecordFolder() throws Exception
{
// Create record
// Create record
doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run()
{
String id = setString("id", GUID.generate());
return rmService.createRecordFolder(rmContainer, id);
return recordFolderService.createRecordFolder(rmContainer, id);
}
@Override
@@ -545,37 +533,36 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(result, getString("id"), TYPE_RECORD_FOLDER);
}
});
// TODO Create record of type
// Failure: Create record with invalid type
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
rmService.createRecordFolder(rmContainer, GUID.generate(), TYPE_FOLDER);
recordFolderService.createRecordFolder(rmContainer, GUID.generate(), TYPE_FOLDER);
}
});
// Failure: Create record folder in root
doTestInTransaction(new FailureTest()
{
@Override
public void run()
{
rmService.createRecordFolder(filePlan, GUID.generate());
recordFolderService.createRecordFolder(filePlan, GUID.generate());
}
});
}
/********** RM2 - Multi-hierarchy record taxonomy's **********/
/**
* Test to create a simple multi-hierarchy record taxonomy
* Test to create a simple multi-hierarchy record taxonomy
*/
@SuppressWarnings("deprecation")
public void testCreateSimpleHierarchy()
{
doTestInTransaction(new Test<Void>()
@@ -584,15 +571,15 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
public Void run()
{
// Create 3 level hierarchy
NodeRef levelOne = setNodeRef("container1", rmService.createRecordCategory(filePlan, "container1"));
NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1"));
assertNotNull("Unable to create container", levelOne);
NodeRef levelTwo = setNodeRef("container2", rmService.createRecordCategory(levelOne, "container2"));
NodeRef levelTwo = setNodeRef("container2", filePlanService.createRecordCategory(levelOne, "container2"));
assertNotNull("Unable to create container", levelTwo);
NodeRef levelThree = setNodeRef("container3", rmService.createRecordCategory(levelTwo, "container3"));
NodeRef levelThree = setNodeRef("container3", filePlanService.createRecordCategory(levelTwo, "container3"));
assertNotNull("Unable to create container", levelThree);
NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", rmService.createRecordFolder(levelThree, "recordFolder3"));
NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", recordFolderService.createRecordFolder(levelThree, "recordFolder3"));
assertNotNull("Unable to create record folder", levelThreeRecordFolder);
return null;
}
@@ -604,25 +591,25 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
basicRMContainerCheck(getNodeRef("container2"), "container2", TYPE_RECORD_CATEGORY);
basicRMContainerCheck(getNodeRef("container3"), "container3", TYPE_RECORD_CATEGORY);
basicRMContainerCheck(getNodeRef("recordFolder3"), "recordFolder3", TYPE_RECORD_FOLDER);
// TODO need to check that the parents and children can be retrieved correctly
}
});
});
}
/**
* A basic test of a records management container
*
*
* @param nodeRef node reference
* @param name name of the container
* @param type the type of container
* @param type the type of container
*/
private void basicRMContainerCheck(NodeRef nodeRef, String name, QName type)
{
// Check the basic details
assertEquals(name, nodeService.getProperty(nodeRef, PROP_NAME));
assertNotNull("RM id has not been set", nodeService.getProperty(nodeRef, PROP_IDENTIFIER));
assertEquals(type, nodeService.getType(nodeRef));
assertEquals(type, nodeService.getType(nodeRef));
}
}

View File

@@ -33,7 +33,7 @@ import org.alfresco.util.GUID;
/**
* Vital record service implementation unit test.
*
*
* @author Roy Wetherall
*/
public class VitalRecordServiceImplTest extends BaseRMTestCase
@@ -42,31 +42,31 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
protected static final Period PERIOD_NONE = new Period("none|0");
protected static final Period PERIOD_WEEK = new Period("week|1");
protected static final Period PERIOD_MONTH = new Period("month|1");
/** Test records */
private NodeRef mhRecord51;
private NodeRef mhRecord52;
private NodeRef mhRecord53;
private NodeRef mhRecord54;
private NodeRef mhRecord55;
/**
* Indicate this test uses the collaboration site test data
/**
* Indicate this test uses the collaboration site test data
*/
@Override
protected boolean isCollaborationSiteTest()
{
return true;
}
/** Indicate this is a multi hierarchy test */
@Override
protected boolean isMultiHierarchyTest()
{
return true;
}
/** vital record multi-hierarchy test data
/** vital record multi-hierarchy test data
*
* |--rmRootContainer (no vr def)
* |
@@ -77,7 +77,7 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
* | |--mhContainer-2-1 (vr def)
* | |
* | |--mhContainer-3-1 (no vr def)
* |
* |
* |--mhContainer-1-2 (has schedule - folder level) (no vr def)
* |
* |--mhContainer-2-2 (no vr def)
@@ -85,26 +85,26 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
* | |--mhContainer-3-2 (vr def disabled)
* | |
* | |--mhContainer-3-3 (has schedule - record level) (vr def)
* |
* |
* |--mhContainer-2-3 (has schedule - folder level) (vr def)
* |
* |--mhContainer-3-4 (no vr def)
* |
* |--mhContainer-3-5 (has schedule- record level) (vr def)
*/
* |
* |--mhContainer-3-5 (has schedule- record level) (vr def)
*/
@Override
protected void setupMultiHierarchyTestData()
{
// Load core test data
super.setupMultiHierarchyTestData();
// Setup vital record definitions
setupVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK);
setupVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK);
setupVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK);
setupVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK);
setupVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH);
// Create records
retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Object>()
{
@@ -116,15 +116,15 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
mhRecord53 = utils.createRecord(mhRecordFolder43, "record53.txt");
mhRecord54 = utils.createRecord(mhRecordFolder44, "record54.txt");
mhRecord55 = utils.createRecord(mhRecordFolder45, "record55.txt");
return null;
}
});
});
}
/**
* Helper to set up the vital record definition data in a transactional manner.
*
*
* @param nodeRef
* @param enabled
* @param period
@@ -142,10 +142,10 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
}
});
}
/**
* Based on the initial data:
* - check category, folder and record raw values.
* - check category, folder and record raw values.
* - check search aspect values.
*/
public void testInit()
@@ -154,7 +154,7 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
{
@Override
public Void run()
{
{
assertHasVitalRecordDefinition(mhContainer, false, null);
assertHasVitalRecordDefinition(mhContainer11, false, null);
assertHasVitalRecordDefinition(mhContainer12, false, null);
@@ -166,24 +166,24 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhRecordFolder41, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhRecordFolder42, false, null);
assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH);
assertVitalRecord(mhRecord51, true, PERIOD_WEEK);
assertVitalRecord(mhRecord52, false, null);
assertVitalRecord(mhRecord53, true, PERIOD_WEEK);
assertVitalRecord(mhRecord54, true, PERIOD_WEEK);
assertVitalRecord(mhRecord55, true, PERIOD_MONTH);
return null;
}
});
});
}
/**
* Test that when new record categories and record folders are created in an existing file plan
* structure that they correctly inherit the correct vital record property values
@@ -195,26 +195,26 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
{
@Override
public NodeRef run()
{
{
return filePlanService.createRecordCategory(mhContainer35, GUID.generate());
}
@Override
public void test(NodeRef result) throws Exception
{
assertHasVitalRecordDefinition(result, true, PERIOD_MONTH);
}
});
// Test record folder value inheritance
doTestInTransaction(new Test<NodeRef>()
{
@Override
public NodeRef run()
{
return rmService.createRecordFolder(mhContainer32, GUID.generate());
{
return recordFolderService.createRecordFolder(mhContainer32, GUID.generate());
}
@Override
public void test(NodeRef result) throws Exception
{
@@ -222,9 +222,9 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
}
});
}
/** Filling tests */
public void testFileNewContent() throws Exception
{
doTestInTransaction(new Test<NodeRef>()
@@ -233,23 +233,23 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
public NodeRef run()
{
NodeRef record = fileFolderService.create(mhRecordFolder41, "test101.txt" , TYPE_CONTENT).getNodeRef();
ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true);
writer.setEncoding("UTF-8");
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
writer.putContent("hello world this is some test content");
return record;
}
@Override
public void test(NodeRef record) throws Exception
public void test(NodeRef record) throws Exception
{
assertVitalRecord(record, true, PERIOD_WEEK);
}
});
}
});
}
// public void testFileUnfiledrecord() throws Exception
// {
// doTestInTransaction(new Test<NodeRef>()
@@ -257,20 +257,20 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
// @Override
// public NodeRef run() throws Exception
// {
// recordService.createRecord(filePlan, dmDocument);
// recordService.createRecord(filePlan, dmDocument);
// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt");
//
//
// return dmDocument;
// }
//
//
// @Override
// public void test(NodeRef record) throws Exception
// public void test(NodeRef record) throws Exception
// {
// assertVitalRecord(record, true, PERIOD_WEEK);
// }
// });
// }
// });
// }
//
//
// public void testFileDirectlyFromCollab() throws Exception
// {
// doTestInTransaction(new Test<NodeRef>()
@@ -281,17 +281,17 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt");
// return dmDocument;
// }
//
//
// @Override
// public void test(NodeRef record) throws Exception
// public void test(NodeRef record) throws Exception
// {
// assertVitalRecord(record, true, PERIOD_WEEK);
// }
// });
// }
// });
// }
/** Helper Methods */
/**
* Test to ensure that changes made to vital record definitions are reflected down the hierarchy.
*/
@@ -302,14 +302,14 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
{
@Override
public Void run()
{
{
setupVitalRecordDefinition(mhContainer31, true, PERIOD_MONTH);
return null;
}
@Override
public void test(Void result) throws Exception
{
{
assertHasVitalRecordDefinition(mhContainer, false, null);
assertHasVitalRecordDefinition(mhContainer11, false, null);
assertHasVitalRecordDefinition(mhContainer12, false, null);
@@ -321,13 +321,13 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhRecordFolder41, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhRecordFolder42, false, null);
assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH);
assertVitalRecord(mhRecord51, true, PERIOD_MONTH);
assertVitalRecord(mhRecord52, false, null);
assertVitalRecord(mhRecord53, true, PERIOD_WEEK);
@@ -335,20 +335,20 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
assertVitalRecord(mhRecord55, true, PERIOD_MONTH);
}
});
// 'turn off' vital record def
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
{
setupVitalRecordDefinition(mhContainer31, false, PERIOD_NONE);
return null;
}
@Override
public void test(Void result) throws Exception
{
{
assertHasVitalRecordDefinition(mhContainer, false, null);
assertHasVitalRecordDefinition(mhContainer11, false, null);
assertHasVitalRecordDefinition(mhContainer12, false, null);
@@ -360,13 +360,13 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhRecordFolder41, false, null);
assertHasVitalRecordDefinition(mhRecordFolder42, false, null);
assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK);
assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH);
assertVitalRecord(mhRecord51, false, null);
assertVitalRecord(mhRecord52, false, null);
assertVitalRecord(mhRecord53, true, PERIOD_WEEK);
@@ -374,20 +374,20 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
assertVitalRecord(mhRecord55, true, PERIOD_MONTH);
}
});
// Test parent change overrites existing
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
{
setupVitalRecordDefinition(mhContainer12, true, PERIOD_MONTH);
return null;
}
@Override
public void test(Void result) throws Exception
{
{
assertHasVitalRecordDefinition(mhContainer, false, null);
assertHasVitalRecordDefinition(mhContainer11, false, null);
assertHasVitalRecordDefinition(mhContainer12, true, PERIOD_MONTH);
@@ -399,13 +399,13 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhRecordFolder41, false, null);
assertHasVitalRecordDefinition(mhRecordFolder42, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_MONTH);
assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH);
assertVitalRecord(mhRecord51, false, null);
assertVitalRecord(mhRecord52, true, PERIOD_MONTH);
assertVitalRecord(mhRecord53, true, PERIOD_MONTH);
@@ -413,22 +413,22 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
assertVitalRecord(mhRecord55, true, PERIOD_MONTH);
}
});
}
@SuppressWarnings("deprecation")
private void assertHasVitalRecordDefinition(NodeRef nodeRef, boolean enabled, Period period)
{
assertTrue(nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD_DEFINITION));
VitalRecordDefinition def = vitalRecordService.getVitalRecordDefinition(nodeRef);
assertNotNull(def);
Boolean vitalRecordIndicator = (Boolean)nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR);
assertNotNull(vitalRecordIndicator);
assertEquals(enabled, vitalRecordIndicator.booleanValue());
assertEquals(enabled, def.isEnabled());
if (enabled == true)
{
Period reviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD);
@@ -438,17 +438,17 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
assertEquals(period.getNextDate(new Date()).getDate(), def.getNextReviewDate().getDate());
}
}
@SuppressWarnings("deprecation")
private void assertVitalRecord(NodeRef nodeRef, boolean enabled, Period period)
{
assertEquals(enabled, nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD));
assertEquals(enabled, nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD));
if (enabled == true)
{
Date reviewAsOf = (Date)nodeService.getProperty(nodeRef, PROP_REVIEW_AS_OF);
assertNotNull(reviewAsOf);
assertEquals(period.getNextDate(new Date()).getDate(), reviewAsOf.getDate());
assertEquals(period.getPeriodType(), nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD));
assertEquals(period.getExpression(), nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION));
}

View File

@@ -24,7 +24,6 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
@@ -38,6 +37,7 @@ import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RmSiteType;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
@@ -124,7 +124,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
protected TaggingService taggingService;
/** RM Services */
protected RecordsManagementService rmService;
protected DispositionService dispositionService;
protected RecordsManagementEventService eventService;
protected RecordsManagementAdminService adminService;
@@ -139,6 +138,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
protected RecordService recordService;
protected FilePlanService filePlanService;
protected FilePlanAuthenticationService filePlanAuthenticationService;
protected RecordFolderService recordFolderService;
/** test data */
protected String siteId;
@@ -295,7 +295,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
// Get the application context
applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS);
utils = new CommonRMTestUtils(applicationContext);
// Initialise the service beans
initServices();
@@ -358,7 +358,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
taggingService = (TaggingService)applicationContext.getBean("TaggingService");
// Get RM services
rmService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService");
dispositionService = (DispositionService)applicationContext.getBean("DispositionService");
eventService = (RecordsManagementEventService)applicationContext.getBean("RecordsManagementEventService");
adminService = (RecordsManagementAdminService)applicationContext.getBean("RecordsManagementAdminService");
@@ -373,6 +372,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
recordService = (RecordService) applicationContext.getBean("RecordService");
filePlanService = (FilePlanService) applicationContext.getBean("FilePlanService");
filePlanAuthenticationService = (FilePlanAuthenticationService) applicationContext.getBean("FilePlanAuthenticationService");
recordFolderService = (RecordFolderService) applicationContext.getBean("RecordFolderService");
}
/**
@@ -414,19 +414,19 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
freezeService.relinquish(hold);
}
}
if (nodeService.exists(folder) == true)
{
// Delete the folder
nodeService.deleteNode(folder);
}
if (siteService.getSite(siteId) != null)
{
// Delete the site
siteService.deleteSite(siteId);
}
// delete the collaboration site (if required)
if (isCollaborationSiteTest() == true && siteService.getSite(COLLABORATION_SITE_ID) != null)
{
@@ -510,7 +510,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
ContentModel.TYPE_FOLDER,
containerProps).getChildRef();
assertNotNull("Could not create base folder", folder);
permissionService.setPermission(folder, "rmadmin", PermissionService.WRITE, true);
permissionService.setPermission(folder, "rmadmin", PermissionService.ADD_CHILDREN, true);
@@ -534,7 +534,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
dispositionSchedule = utils.createBasicDispositionSchedule(rmContainer);
// Create RM folder
rmFolder = rmService.createRecordFolder(rmContainer, "rmFolder");
rmFolder = recordFolderService.createRecordFolder(rmContainer, "rmFolder");
assertNotNull("Could not create rm folder", rmFolder);
}
@@ -687,11 +687,11 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
mhDispositionSchedule35 = utils.createBasicDispositionSchedule(mhContainer35, "ds35", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, true, true);
// Record folders
mhRecordFolder41 = rmService.createRecordFolder(mhContainer31, "mhFolder41");
mhRecordFolder42 = rmService.createRecordFolder(mhContainer32, "mhFolder42");
mhRecordFolder43 = rmService.createRecordFolder(mhContainer33, "mhFolder43");
mhRecordFolder44 = rmService.createRecordFolder(mhContainer34, "mhFolder44");
mhRecordFolder45 = rmService.createRecordFolder(mhContainer35, "mhFolder45");
mhRecordFolder41 = recordFolderService.createRecordFolder(mhContainer31, "mhFolder41");
mhRecordFolder42 = recordFolderService.createRecordFolder(mhContainer32, "mhFolder42");
mhRecordFolder43 = recordFolderService.createRecordFolder(mhContainer33, "mhFolder43");
mhRecordFolder44 = recordFolderService.createRecordFolder(mhContainer34, "mhFolder44");
mhRecordFolder45 = recordFolderService.createRecordFolder(mhContainer35, "mhFolder45");
}
protected void setupCollaborationSiteTestData()

View File

@@ -23,7 +23,6 @@ import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
@@ -34,6 +33,7 @@ import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventSe
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RmSiteType;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
@@ -96,7 +96,6 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
protected TaggingService taggingService;
/** RM Services */
protected RecordsManagementService rmService;
protected DispositionService dispositionService;
protected RecordsManagementEventService eventService;
protected RecordsManagementAdminService adminService;
@@ -108,6 +107,7 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
protected CapabilityService capabilityService;
protected VitalRecordService vitalRecordService;
protected FilePlanService filePlanService;
protected RecordFolderService recordFolderService;
/** test data */
protected String siteId;
@@ -169,7 +169,6 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
taggingService = (TaggingService)applicationContext.getBean("TaggingService");
// Get RM services
rmService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService");
dispositionService = (DispositionService)applicationContext.getBean("DispositionService");
eventService = (RecordsManagementEventService)applicationContext.getBean("RecordsManagementEventService");
adminService = (RecordsManagementAdminService)applicationContext.getBean("RecordsManagementAdminService");
@@ -181,6 +180,7 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
capabilityService = (CapabilityService)applicationContext.getBean("CapabilityService");
vitalRecordService = (VitalRecordService)applicationContext.getBean("VitalRecordService");
filePlanService = (FilePlanService)applicationContext.getBean("FilePlanService");
recordFolderService = (RecordFolderService)applicationContext.getBean("RecordFolderService");
}
/**
@@ -293,9 +293,9 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
dispositionSchedule = utils.createBasicDispositionSchedule(recordCategory);
// Create RM folder
recordFolder = rmService.createRecordFolder(recordCategory, "rmFolder");
recordFolder = recordFolderService.createRecordFolder(recordCategory, "rmFolder");
assertNotNull("Could not create rm folder", recordFolder);
recordFolder2 = rmService.createRecordFolder(recordCategory, "rmFolder2");
recordFolder2 = recordFolderService.createRecordFolder(recordCategory, "rmFolder2");
assertNotNull("Could not create rm folder 2", recordFolder2);
// Create collaboration data

View File

@@ -38,7 +38,7 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
/**
* This class tests the Rest API for disposition related operations
*
*
* @author Gavin Cornwell
*/
public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel
@@ -52,7 +52,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
protected static final String GET_LIST_URL = "/api/rma/admin/listofvalues";
protected static final String SERVICE_URL_PREFIX = "/alfresco/service";
protected static final String APPLICATION_JSON = "application/json";
public void testGetDispositionSchedule() throws Exception
{
@@ -61,50 +61,50 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
String nonExistentNode = "workspace/SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx";
String nonExistentUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, nonExistentNode);
Response rsp = sendRequest(new GetRequest(nonExistentUrl), expectedStatus);
// Test 404 status for node that doesn't have dispostion schedule i.e. a record series
String seriesNodeUrl = recordSeries.toString().replace("://", "/");
String wrongNodeUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, seriesNodeUrl);
rsp = sendRequest(new GetRequest(wrongNodeUrl), expectedStatus);
// Test data structure returned from "AIS Audit Records"
expectedStatus = 200;
String categoryNodeUrl = recordCategory.toString().replace("://", "/");
String requestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl);
rsp = sendRequest(new GetRequest(requestUrl), expectedStatus);
assertEquals("application/json;charset=UTF-8", rsp.getContentType());
// get response as JSON
JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString()));
assertNotNull(jsonParsedObject);
// check JSON data
JSONObject dataObj = jsonParsedObject.getJSONObject("data");
assertNotNull(dataObj);
JSONObject rootDataObject = (JSONObject)dataObj;
assertEquals(10, rootDataObject.length());
// check individual data items
String serviceUrl = SERVICE_URL_PREFIX + requestUrl;
String url = rootDataObject.getString("url");
assertEquals(serviceUrl, url);
String authority = rootDataObject.getString("authority");
assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, authority);
String instructions = rootDataObject.getString("instructions");
assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, instructions);
String actionsUrl = rootDataObject.getString("actionsUrl");
assertEquals(serviceUrl + "/dispositionactiondefinitions", actionsUrl);
boolean recordLevel = rootDataObject.getBoolean("recordLevelDisposition");
assertFalse(recordLevel);
assertFalse(rootDataObject.getBoolean("canStepsBeRemoved"));
JSONArray actions = rootDataObject.getJSONArray("actions");
assertNotNull(actions);
assertEquals(2, actions.length());
@@ -115,25 +115,25 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertEquals(0, action1.getInt("index"));
assertEquals("cutoff", action1.getString("name"));
assertTrue(action1.getBoolean("eligibleOnFirstCompleteEvent"));
JSONObject action2 = (JSONObject)actions.get(1);
assertEquals(8, action2.length());
// make sure the disposition schedule node ref is present and valid
String scheduleNodeRefJSON = rootDataObject.getString("nodeRef");
NodeRef scheduleNodeRef = new NodeRef(scheduleNodeRefJSON);
assertTrue(this.nodeService.exists(scheduleNodeRef));
// create a new recordCategory node in the recordSeries and then get
// the disposition schedule
NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate());
dispositionService.createDispositionSchedule(newRecordCategory, null);
categoryNodeUrl = newRecordCategory.toString().replace("://", "/");
requestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl);
//System.out.println("GET response: " + rsp.getContentAsString());
rsp = sendRequest(new GetRequest(requestUrl), expectedStatus);
// get response as JSON
jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString()));
System.out.println(rsp.getContentAsString());
@@ -148,24 +148,24 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertNotNull(actions);
assertEquals(0, actions.length());
}
public void testPostDispositionAction() throws Exception
{
// create a new recordCategory node in the recordSeries and then get
// the disposition schedule
NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate());
dispositionService.createDispositionSchedule(newRecordCategory, null);
String categoryNodeUrl = newRecordCategory.toString().replace("://", "/");
String requestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl);
// Construct the JSON request.
String name = "destroy";
String desc = "Destroy this record after 5 years";
String period = "year|5";
String periodProperty = "rma:cutOffDate";
boolean eligibleOnFirstCompleteEvent = true;
JSONObject jsonPostData = new JSONObject();
jsonPostData.put("name", name);
jsonPostData.put("description", desc);
@@ -177,11 +177,11 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
events.put("superseded");
events.put("no_longer_needed");
jsonPostData.put("events", events);
// Submit the JSON request.
String jsonPostString = jsonPostData.toString();
Response rsp = sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 200);
// check the returned data is what was expected
JSONObject jsonResponse = new JSONObject(new JSONTokener(rsp.getContentAsString()));
JSONObject dataObj = jsonResponse.getJSONObject("data");
@@ -201,13 +201,13 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertEquals(2, events.length());
assertEquals("superseded", events.get(0));
assertEquals("no_longer_needed", events.get(1));
// test the minimum amount of data required to create an action definition
jsonPostData = new JSONObject();
jsonPostData.put("name", name);
jsonPostString = jsonPostData.toString();
rsp = sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 200);
// check the returned data is what was expected
jsonResponse = new JSONObject(new JSONTokener(rsp.getContentAsString()));
dataObj = jsonResponse.getJSONObject("data");
@@ -220,7 +220,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertFalse(dataObj.has("periodProperty"));
assertFalse(dataObj.has("events"));
assertTrue(dataObj.getBoolean("eligibleOnFirstCompleteEvent"));
// negative test to ensure not supplying mandatory data results in an error
jsonPostData = new JSONObject();
jsonPostData.put("description", desc);
@@ -228,12 +228,12 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
jsonPostString = jsonPostData.toString();
sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 400);
}
public void testPutDispositionAction() throws Exception
{
NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate());
dispositionService.createDispositionSchedule(newRecordCategory, null);
// create an action definition to then update
String categoryNodeUrl = newRecordCategory.toString().replace("://", "/");
String postRequestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl);
@@ -241,7 +241,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
jsonPostData.put("name", "cutoff");
String jsonPostString = jsonPostData.toString();
sendRequest(new PostRequest(postRequestUrl, jsonPostString, APPLICATION_JSON), 200);
// verify the action definition is present and retrieve it's id
String getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl);
Response rsp = sendRequest(new GetRequest(getRequestUrl), 200);
@@ -252,7 +252,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertEquals("none|0", actionDef.getString("period"));
assertFalse(actionDef.has("description"));
assertFalse(actionDef.has("events"));
// define body for PUT request
String name = "destroy";
String desc = "Destroy this record after 5 years";
@@ -260,7 +260,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
String location = "my location";
String periodProperty = "rma:cutOffDate";
boolean eligibleOnFirstCompleteEvent = false;
jsonPostData = new JSONObject();
jsonPostData.put("name", name);
jsonPostData.put("description", desc);
@@ -273,15 +273,15 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
events.put("no_longer_needed");
jsonPostData.put("events", events);
jsonPostString = jsonPostData.toString();
// try and update a non existent action definition to check for 404
String putRequestUrl = MessageFormat.format(PUT_ACTIONDEF_URL_FORMAT, categoryNodeUrl, "xyz");
rsp = sendRequest(new PutRequest(putRequestUrl, jsonPostString, APPLICATION_JSON), 404);
// update the action definition
putRequestUrl = MessageFormat.format(PUT_ACTIONDEF_URL_FORMAT, categoryNodeUrl, actionDefId);
rsp = sendRequest(new PutRequest(putRequestUrl, jsonPostString, APPLICATION_JSON), 200);
// check the update happened correctly
json = new JSONObject(new JSONTokener(rsp.getContentAsString()));
actionDef = json.getJSONObject("data");
@@ -296,12 +296,12 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertEquals("superseded", actionDef.getJSONArray("events").getString(0));
assertEquals("no_longer_needed", actionDef.getJSONArray("events").getString(1));
}
public void testDeleteDispositionAction() throws Exception
{
NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate());
dispositionService.createDispositionSchedule(newRecordCategory, null);
// create an action definition to then delete
String categoryNodeUrl = newRecordCategory.toString().replace("://", "/");
String postRequestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl);
@@ -309,21 +309,21 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
jsonPostData.put("name", "cutoff");
String jsonPostString = jsonPostData.toString();
sendRequest(new PostRequest(postRequestUrl, jsonPostString, APPLICATION_JSON), 200);
// verify the action definition is present and retrieve it's id
String getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl);
Response rsp = sendRequest(new GetRequest(getRequestUrl), 200);
JSONObject json = new JSONObject(new JSONTokener(rsp.getContentAsString()));
String actionDefId = json.getJSONObject("data").getJSONArray("actions").getJSONObject(0).getString("id");
// try and delete a non existent action definition to check for 404
String deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, "xyz");
rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 404);
// now delete the action defintion created above
deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, actionDefId);
rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 200);
// verify it got deleted
getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl);
rsp = sendRequest(new GetRequest(getRequestUrl), 200);
@@ -331,30 +331,30 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
JSONArray actions = json.getJSONObject("data").getJSONArray("actions");
assertEquals(0, actions.length());
}
public void testGetDispositionLifecycle() throws Exception
{
// Test 404 for disposition lifecycle request on incorrect node
String categoryUrl = recordCategory.toString().replace("://", "/");
String requestUrl = MessageFormat.format(GET_LIFECYCLE_URL_FORMAT, categoryUrl);
Response rsp = sendRequest(new GetRequest(requestUrl), 200);
JSONObject notFound = new JSONObject(new JSONTokener(rsp.getContentAsString()));
assertEquals(true, notFound.getJSONObject("data").getBoolean("notFound"));
NodeRef newRecordFolder = rmService.createRecordFolder(recordCategory, "recordFolder");
NodeRef newRecordFolder = recordFolderService.createRecordFolder(recordCategory, "recordFolder");
// there should now be a disposition lifecycle for the record
requestUrl = MessageFormat.format(GET_LIFECYCLE_URL_FORMAT, newRecordFolder.toString().replace("://", "/"));
rsp = sendRequest(new GetRequest(requestUrl), 200);
System.out.println("GET : " + rsp.getContentAsString());
assertEquals("application/json;charset=UTF-8", rsp.getContentType());
// get response as JSON
JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString()));
assertNotNull(jsonParsedObject);
// check mandatory stuff is present
JSONObject dataObj = jsonParsedObject.getJSONObject("data");
assertEquals(SERVICE_URL_PREFIX + requestUrl, dataObj.getString("url"));
@@ -368,7 +368,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertEquals("Case Closed", event1.get("label"));
assertFalse(event1.getBoolean("complete"));
assertFalse(event1.getBoolean("automatic"));
// check stuff expected to be missing is missing
assertFalse(dataObj.has("asOf"));
assertFalse(dataObj.has("startedAt"));
@@ -378,18 +378,18 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertFalse(event1.has("completedAt"));
assertFalse(event1.has("completedBy"));
}
public void testGetListOfValues() throws Exception
{
// call the list service
Response rsp = sendRequest(new GetRequest(GET_LIST_URL), 200);
Response rsp = sendRequest(new GetRequest(GET_LIST_URL), 200);
assertEquals("application/json;charset=UTF-8", rsp.getContentType());
// get response as JSON
JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString()));
assertNotNull(jsonParsedObject);
JSONObject data = jsonParsedObject.getJSONObject("data");
// check dispostion actions
JSONObject actions = data.getJSONObject("dispositionActions");
assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/dispositionactions", actions.getString("url"));
@@ -400,7 +400,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertTrue(item.length() == 2);
assertTrue(item.has("label"));
assertTrue(item.has("value"));
// check events
JSONObject events = data.getJSONObject("events");
assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/events", events.getString("url"));
@@ -412,7 +412,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertTrue(item.has("label"));
assertTrue(item.has("value"));
assertTrue(item.has("automatic"));
// check period types
JSONObject periodTypes = data.getJSONObject("periodTypes");
assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/periodtypes", periodTypes.getString("url"));
@@ -423,7 +423,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R
assertTrue(item.length() == 2);
assertTrue(item.has("label"));
assertTrue(item.has("value"));
// check period properties
JSONObject periodProperties = data.getJSONObject("periodProperties");
assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/periodproperties", periodProperties.getString("url"));