Fixed failing test

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@47316 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-02-28 15:06:21 +00:00
parent 5198e95a2b
commit 72c40e7585
2 changed files with 60 additions and 60 deletions

View File

@@ -96,7 +96,7 @@ public class NodeParameterProcessor extends ParameterProcessor
value = stripName(value); value = stripName(value);
if (value.isEmpty() == false) if (value.isEmpty() == false)
{ {
QName qname = QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, value, namespaceService); QName qname = QName.createQName(value, namespaceService);
PropertyDefinition propertyDefinition = dictionaryService.getProperty(qname); PropertyDefinition propertyDefinition = dictionaryService.getProperty(qname);
if (propertyDefinition == null) if (propertyDefinition == null)

View File

@@ -36,7 +36,7 @@ import org.springframework.util.StringUtils;
/** /**
* FileTo action unit test * FileTo action unit test
* *
* @author Roy Wetherall * @author Roy Wetherall
* @since 2.1 * @since 2.1
*/ */
@@ -46,9 +46,9 @@ public class FileToActionTest extends BaseRMTestCase
private static final String PATH2 = "/rmcontainer/rmfolder"; private static final String PATH2 = "/rmcontainer/rmfolder";
private static final String PATH_BAD = "monkey/rmfolder"; private static final String PATH_BAD = "monkey/rmfolder";
private static final String PATH_CREATE = "rmcontainer/newrmfolder"; private static final String PATH_CREATE = "rmcontainer/newrmfolder";
private static final String PATH_SUB1 = "rmcontainer/${node.name}"; private static final String PATH_SUB1 = "rmcontainer/${node.cm:name}";
protected ActionService dmActionService; protected ActionService dmActionService;
@Override @Override
@@ -57,55 +57,55 @@ public class FileToActionTest extends BaseRMTestCase
super.initServices(); super.initServices();
dmActionService = (ActionService) applicationContext.getBean("ActionService"); dmActionService = (ActionService) applicationContext.getBean("ActionService");
} }
@Override @Override
protected boolean isCollaborationSiteTest() protected boolean isCollaborationSiteTest()
{ {
return true; return true;
} }
@Override @Override
protected boolean isUserTest() protected boolean isUserTest()
{ {
return true; return true;
} }
public void testFileToNodeRef() public void testFileToNodeRef()
{ {
initRecord(); initRecord();
doTestInTransaction(new Test<Void>() doTestInTransaction(new Test<Void>()
{ {
public Void run() public Void run()
{ {
NodeRef unfiledContainer = filePlanService.getUnfiledContainer(filePlan); NodeRef unfiledContainer = filePlanService.getUnfiledContainer(filePlan);
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(unfiledContainer, RMPermissionModel.FILING)); assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(unfiledContainer, RMPermissionModel.FILING));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmFolder, RMPermissionModel.FILING)); assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmFolder, RMPermissionModel.FILING));
Capability capability = capabilityService.getCapability("FileToRecords"); Capability capability = capabilityService.getCapability("FileToRecords");
assertNotNull(capability); assertNotNull(capability);
assertEquals(AccessStatus.ALLOWED, capability.hasPermission(dmDocument)); assertEquals(AccessStatus.ALLOWED, capability.hasPermission(dmDocument));
// set parameters // set parameters
Map<String, Serializable> params = new HashMap<String, Serializable>(1); Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(FileToAction.PARAM_DESTINATION_RECORD_FOLDER, rmFolder); params.put(FileToAction.PARAM_DESTINATION_RECORD_FOLDER, rmFolder);
// execute file-to action // execute file-to action
actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params);
// check things have gone according to plan // check things have gone according to plan
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
assertTrue(recordService.isFiled(dmDocument)); assertTrue(recordService.isFiled(dmDocument));
// is the record folder the primary parent of the filed record // is the record folder the primary parent of the filed record
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
assertEquals(rmFolder, parent); assertEquals(rmFolder, parent);
return null; return null;
} }
}, rmAdminName); }, rmAdminName);
} }
private void initRecord() private void initRecord()
{ {
doTestInTransaction(new Test<Void>() doTestInTransaction(new Test<Void>()
@@ -114,24 +114,24 @@ public class FileToActionTest extends BaseRMTestCase
{ {
// create record from document // create record from document
recordService.createRecord(filePlan, dmDocument); recordService.createRecord(filePlan, dmDocument);
// check things have gone according to plan // check things have gone according to plan
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
assertFalse(recordService.isFiled(dmDocument)); assertFalse(recordService.isFiled(dmDocument));
// is the unfiled container the primary parent of the filed record // is the unfiled container the primary parent of the filed record
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
assertEquals(filePlanService.getUnfiledContainer(filePlan), parent); assertEquals(filePlanService.getUnfiledContainer(filePlan), parent);
return null; return null;
} }
}, dmCollaborator); }, dmCollaborator);
} }
public void testFileToPath() public void testFileToPath()
{ {
initRecord(); initRecord();
doTestInTransaction(new Test<Void>() doTestInTransaction(new Test<Void>()
{ {
public Void run() public Void run()
@@ -139,27 +139,27 @@ public class FileToActionTest extends BaseRMTestCase
// set parameters // set parameters
Map<String, Serializable> params = new HashMap<String, Serializable>(1); Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(FileToAction.PARAM_PATH, PATH); params.put(FileToAction.PARAM_PATH, PATH);
// execute file-to action // execute file-to action
actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params);
// check things have gone according to plan // check things have gone according to plan
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
assertTrue(recordService.isFiled(dmDocument)); assertTrue(recordService.isFiled(dmDocument));
// is the record folder the primary parent of the filed record // is the record folder the primary parent of the filed record
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
assertEquals(rmFolder, parent); assertEquals(rmFolder, parent);
return null; return null;
} }
}, rmAdminName); }, rmAdminName);
} }
public void testFileToPath2() public void testFileToPath2()
{ {
initRecord(); initRecord();
doTestInTransaction(new Test<Void>() doTestInTransaction(new Test<Void>()
{ {
public Void run() public Void run()
@@ -167,40 +167,40 @@ public class FileToActionTest extends BaseRMTestCase
// set parameters // set parameters
Map<String, Serializable> params = new HashMap<String, Serializable>(1); Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(FileToAction.PARAM_PATH, PATH2); params.put(FileToAction.PARAM_PATH, PATH2);
// execute file-to action // execute file-to action
actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params);
// check things have gone according to plan // check things have gone according to plan
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
assertTrue(recordService.isFiled(dmDocument)); assertTrue(recordService.isFiled(dmDocument));
// is the record folder the primary parent of the filed record // is the record folder the primary parent of the filed record
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
assertEquals(rmFolder, parent); assertEquals(rmFolder, parent);
return null; return null;
} }
}, rmAdminName); }, rmAdminName);
} }
public void testCreate() throws Exception public void testCreate() throws Exception
{ {
initRecord(); initRecord();
createRecord(PATH_CREATE, "newrmfolder"); createRecord(PATH_CREATE, "newrmfolder");
} }
public void testCreateSub() throws Exception public void testCreateSub() throws Exception
{ {
initRecord(); initRecord();
createRecord(PATH_SUB1, "collabDocument.txt", "rmcontainer/collabDocument.txt"); createRecord(PATH_SUB1, "collabDocument.txt", "rmcontainer/collabDocument.txt");
} }
private void createRecord(String path, String name) private void createRecord(String path, String name)
{ {
createRecord(path, name, path); createRecord(path, name, path);
} }
private void createRecord(final String path, final String name, final String resolvedPath) private void createRecord(final String path, final String name, final String resolvedPath)
{ {
doTestInTransaction(new Test<Void>() doTestInTransaction(new Test<Void>()
@@ -208,38 +208,38 @@ public class FileToActionTest extends BaseRMTestCase
public Void run() throws Exception public Void run() throws Exception
{ {
String[] pathValues = StringUtils.tokenizeToStringArray(resolvedPath, "/"); String[] pathValues = StringUtils.tokenizeToStringArray(resolvedPath, "/");
// show the folder doesn't exist to begin with // show the folder doesn't exist to begin with
FileInfo createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList<String>(Arrays.asList(pathValues)), false); FileInfo createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList<String>(Arrays.asList(pathValues)), false);
assertNull(createdRecordFolder); assertNull(createdRecordFolder);
// set parameters // set parameters
Map<String, Serializable> params = new HashMap<String, Serializable>(1); Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(FileToAction.PARAM_PATH, path); params.put(FileToAction.PARAM_PATH, path);
params.put(FileToAction.PARAM_CREATE_RECORD_FOLDER, true); params.put(FileToAction.PARAM_CREATE_RECORD_FOLDER, true);
// execute file-to action // execute file-to action
actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params);
// show the folder has now been created // show the folder has now been created
createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList<String>(Arrays.asList(pathValues)), false); createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList<String>(Arrays.asList(pathValues)), false);
assertNotNull(createdRecordFolder); assertNotNull(createdRecordFolder);
assertEquals(name, createdRecordFolder.getName()); assertEquals(name, createdRecordFolder.getName());
NodeRef createdRecordFolderNodeRef = createdRecordFolder.getNodeRef(); NodeRef createdRecordFolderNodeRef = createdRecordFolder.getNodeRef();
// check things have gone according to plan // check things have gone according to plan
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
assertTrue(recordService.isFiled(dmDocument)); assertTrue(recordService.isFiled(dmDocument));
// is the record folder the primary parent of the filed record // is the record folder the primary parent of the filed record
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
assertEquals(createdRecordFolderNodeRef, parent); assertEquals(createdRecordFolderNodeRef, parent);
return null; return null;
} }
}, rmAdminName); }, rmAdminName);
} }
public void failureTests() throws Exception public void failureTests() throws Exception
{ {
doTestInTransaction(new Test<Void>() doTestInTransaction(new Test<Void>()
@@ -248,55 +248,55 @@ public class FileToActionTest extends BaseRMTestCase
{ {
// create record from document // create record from document
recordService.createRecord(filePlan, dmDocument); recordService.createRecord(filePlan, dmDocument);
// check things have gone according to plan // check things have gone according to plan
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
assertFalse(recordService.isFiled(dmDocument)); assertFalse(recordService.isFiled(dmDocument));
// is the unfiled container the primary parent of the filed record // is the unfiled container the primary parent of the filed record
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
assertEquals(filePlanService.getUnfiledContainer(filePlan), parent); assertEquals(filePlanService.getUnfiledContainer(filePlan), parent);
return null; return null;
} }
}, dmCollaborator); }, dmCollaborator);
doTestInTransaction(new FailureTest doTestInTransaction(new FailureTest
( (
"Path is invalid and record create not set." "Path is invalid and record create not set."
) )
{ {
@Override @Override
public void run() throws Exception public void run() throws Exception
{ {
// set parameters // set parameters
Map<String, Serializable> params = new HashMap<String, Serializable>(1); Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(FileToAction.PARAM_PATH, PATH_BAD); params.put(FileToAction.PARAM_PATH, PATH_BAD);
// execute file-to action // execute file-to action
actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params);
} }
}); });
doTestInTransaction(new FailureTest doTestInTransaction(new FailureTest
( (
"Path is for a new folder, but create not set." "Path is for a new folder, but create not set."
) )
{ {
@Override @Override
public void run() throws Exception public void run() throws Exception
{ {
// set parameters // set parameters
Map<String, Serializable> params = new HashMap<String, Serializable>(1); Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(FileToAction.PARAM_PATH, PATH_CREATE); params.put(FileToAction.PARAM_PATH, PATH_CREATE);
// execute file-to action // execute file-to action
actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params);
} }
}); });
} }
} }