RM dependency upgrade (4.2.d)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@49264 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-04-15 20:49:23 +00:00
parent 049869a6c1
commit 54b89a0973
23 changed files with 833 additions and 792 deletions

View File

@@ -58,45 +58,45 @@ import org.springframework.util.CollectionUtils;
/**
* This test class tests the definition and use of a custom RM elements at the Java services layer.
*
*
* @author Neil McErlean, janv, Roy Wetherall
*/
public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
implements RecordsManagementModel,
BeforeCreateReference,
OnCreateReference
{
private final static long testRunID = System.currentTimeMillis();
private List<QName> createdCustomProperties;
private List<QName> createdCustomProperties;
private List<QName> madeCustomisable;
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setUp()
*/
@Override
protected void setUp() throws Exception
{
protected void setUp() throws Exception
{
createdCustomProperties = new ArrayList<QName>();
madeCustomisable = new ArrayList<QName>();
super.setUp();
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestData()
*/
@Override
protected void setupTestData()
protected void setupTestData()
{
super.setupTestData();
super.setupTestData();
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception
protected void tearDown() throws Exception
{
retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Object>()
{
@@ -105,24 +105,24 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
{
// As system user
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
for (QName createdCustomProperty : createdCustomProperties)
for (QName createdCustomProperty : createdCustomProperties)
{
adminService.removeCustomPropertyDefinition(createdCustomProperty);
}
for (QName customisable : madeCustomisable)
for (QName customisable : madeCustomisable)
{
adminService.unmakeCustomisable(customisable);
}
return null;
}
});
});
super.tearDown();
}
/**
* @see RecordsManagementAdminService#getCustomisable()
*/
@@ -139,17 +139,17 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
assertTrue(list.containsAll(
CollectionUtils.arrayToList(new QName[]
{
ASPECT_RECORD,
TYPE_RECORD_FOLDER,
ASPECT_RECORD,
TYPE_RECORD_FOLDER,
TYPE_NON_ELECTRONIC_DOCUMENT,
TYPE_RECORD_CATEGORY
})));
return null;
}
});
}
/**
* @see RecordsManagementAdminService#isCustomisable(QName)
*/
@@ -164,12 +164,12 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
assertFalse(adminService.isCustomisable(ASPECT_DUBLINCORE));
assertTrue(adminService.isCustomisable(TYPE_RECORD_FOLDER));
assertTrue(adminService.isCustomisable(ASPECT_RECORD));
return null;
}
});
}
/**
* @see RecordsManagementAdminService#existsCustomProperty(QName)
* @see RecordsManagementAdminService#addCustomPropertyDefinition(QName, QName, String, QName, String, String, String, boolean, boolean, boolean, QName)
@@ -182,66 +182,66 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
{
@Override
public QName run() throws Exception
{
{
// Check the property does not exist
assertFalse(adminService.existsCustomProperty(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1")));
return adminService.addCustomPropertyDefinition(
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"),
ASPECT_RECORD,
"Label1",
DataTypeDefinition.TEXT,
"Title",
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"),
ASPECT_RECORD,
"Label1",
DataTypeDefinition.TEXT,
"Title",
"Description");
}
@Override
public void test(QName result) throws Exception
public void test(QName result) throws Exception
{
try
{
{
// Check the property QName is correct
assertNotNull(result);
assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), result);
assertTrue(adminService.existsCustomProperty(result));
// Check that property is available as a custom property
Map<QName, PropertyDefinition> propDefs = adminService.getCustomPropertyDefinitions(ASPECT_RECORD);
assertNotNull(propDefs);
assertTrue(propDefs.containsKey(result));
// Check the property definition
PropertyDefinition propDef = propDefs.get(result);
assertNotNull(propDef);
assertNotNull(propDef);
assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName());
assertEquals("Description", propDef.getDescription());
assertEquals("Label1", propDef.getTitle());
assertEquals("Description", propDef.getDescription(dictionaryService));
assertEquals("Label1", propDef.getTitle(dictionaryService));
}
finally
{
// Store the created property for cleanup later
createdCustomProperties.add(result);
}
}
}
});
// Add property to record (no id, short version)
doTestInTransaction(new Test<QName>()
{
@Override
public QName run() throws Exception
{
{
return adminService.addCustomPropertyDefinition(
null,
ASPECT_RECORD,
"Label2",
DataTypeDefinition.TEXT,
"Title",
null,
ASPECT_RECORD,
"Label2",
DataTypeDefinition.TEXT,
"Title",
"Description");
}
@Override
public void test(QName result) throws Exception
public void test(QName result) throws Exception
{
try
{
@@ -249,83 +249,83 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
assertNotNull(result);
assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI());
assertTrue(adminService.existsCustomProperty(result));
// Check that property is available as a custom property
Map<QName, PropertyDefinition> propDefs = adminService.getCustomPropertyDefinitions(ASPECT_RECORD);
assertNotNull(propDefs);
assertTrue(propDefs.containsKey(result));
// Check the property definition
PropertyDefinition propDef = propDefs.get(result);
assertNotNull(propDef);
assertNotNull(propDef);
assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName());
assertEquals("Description", propDef.getDescription());
assertEquals("Label2", propDef.getTitle());
assertEquals("Description", propDef.getDescription(dictionaryService));
assertEquals("Label2", propDef.getTitle(dictionaryService));
}
finally
{
// Store the created property for cleanup later
createdCustomProperties.add(result);
}
}
}
});
// Add property to record (long version)
doTestInTransaction(new Test<QName>()
{
@Override
public QName run() throws Exception
{
{
return adminService.addCustomPropertyDefinition(
null,
ASPECT_RECORD,
"Label3",
DataTypeDefinition.TEXT,
"Title",
"Description",
"default",
false,
false,
false,
null,
ASPECT_RECORD,
"Label3",
DataTypeDefinition.TEXT,
"Title",
"Description",
"default",
false,
false,
false,
null);
}
@Override
public void test(QName result) throws Exception
public void test(QName result) throws Exception
{
try
{
{
// Check the property QName is correct
assertNotNull(result);
assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI());
assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI());
assertTrue(adminService.existsCustomProperty(result));
// Check that property is available as a custom property
Map<QName, PropertyDefinition> propDefs = adminService.getCustomPropertyDefinitions(ASPECT_RECORD);
assertNotNull(propDefs);
//assertEquals(3, propDefs.size());
assertTrue(propDefs.containsKey(result));
// Check the property definition
PropertyDefinition propDef = propDefs.get(result);
assertNotNull(propDef);
assertNotNull(propDef);
assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName());
assertEquals("Description", propDef.getDescription());
assertEquals("Label3", propDef.getTitle());
assertEquals("Description", propDef.getDescription(dictionaryService));
assertEquals("Label3", propDef.getTitle(dictionaryService));
assertEquals("default", propDef.getDefaultValue());
assertFalse(propDef.isMandatory());
assertFalse(propDef.isMultiValued());
assertFalse(propDef.isProtected());
}
finally
{
// Store the created property for cleanup later
createdCustomProperties.add(result);
}
}
}
});
// Failure: Add a property with the same name twice
doTestInTransaction(new FailureTest
(
@@ -337,15 +337,15 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
public void run() throws Exception
{
adminService.addCustomPropertyDefinition(
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"),
ASPECT_RECORD,
"Label1",
DataTypeDefinition.TEXT,
"Title",
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"),
ASPECT_RECORD,
"Label1",
DataTypeDefinition.TEXT,
"Title",
"Description");
}
});
});
// Failure: Try and add a property to a type that isn't customisable
doTestInTransaction(new FailureTest
(
@@ -357,16 +357,16 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
public void run() throws Exception
{
adminService.addCustomPropertyDefinition(
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myContentProp"),
TYPE_CONTENT,
"Label1",
DataTypeDefinition.TEXT,
"Title",
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myContentProp"),
TYPE_CONTENT,
"Label1",
DataTypeDefinition.TEXT,
"Title",
"Description");
}
});
});
}
/**
* @see RecordsManagementAdminService#makeCustomisable(QName)
*/
@@ -382,41 +382,41 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
adminService.makeCustomisable(TYPE_CUSTOM_TYPE);
madeCustomisable.add(TYPE_CUSTOM_TYPE);
assertTrue(adminService.isCustomisable(TYPE_CUSTOM_TYPE));
// Add a custom property
return adminService.addCustomPropertyDefinition(
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"),
TYPE_CUSTOM_TYPE,
"Label",
DataTypeDefinition.TEXT,
"Title",
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"),
TYPE_CUSTOM_TYPE,
"Label",
DataTypeDefinition.TEXT,
"Title",
"Description");
}
@Override
public void test(QName result) throws Exception
public void test(QName result) throws Exception
{
// Check the property QName is correct
assertNotNull(result);
assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), result);
assertTrue(adminService.existsCustomProperty(result));
// Check that property is available as a custom property
Map<QName, PropertyDefinition> propDefs = adminService.getCustomPropertyDefinitions(TYPE_CUSTOM_TYPE);
assertNotNull(propDefs);
assertEquals(1, propDefs.size());
assertTrue(propDefs.containsKey(result));
// Check the property definition
PropertyDefinition propDef = propDefs.get(result);
assertNotNull(propDef);
assertNotNull(propDef);
assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName());
assertEquals("Description", propDef.getDescription());
assertEquals("Label", propDef.getTitle());
assertEquals("Description", propDef.getDescription(dictionaryService));
assertEquals("Label", propDef.getTitle(dictionaryService));
}
});
doTestInTransaction(new Test<QName>()
{
@Override
@@ -427,41 +427,41 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
adminService.makeCustomisable(ASPECT_CUSTOM_ASPECT);
madeCustomisable.add(ASPECT_CUSTOM_ASPECT);
assertTrue(adminService.isCustomisable(ASPECT_CUSTOM_ASPECT));
// Add a custom property
return adminService.addCustomPropertyDefinition(
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"),
ASPECT_CUSTOM_ASPECT,
"Label",
DataTypeDefinition.TEXT,
"Title",
"Description");
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"),
ASPECT_CUSTOM_ASPECT,
"Label",
DataTypeDefinition.TEXT,
"Title",
"Description");
}
@Override
public void test(QName result) throws Exception
public void test(QName result) throws Exception
{
// Check the property QName is correct
assertNotNull(result);
assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), result);
assertTrue(adminService.existsCustomProperty(result));
// Check that property is available as a custom property
Map<QName, PropertyDefinition> propDefs = adminService.getCustomPropertyDefinitions(ASPECT_CUSTOM_ASPECT);
assertNotNull(propDefs);
assertEquals(1, propDefs.size());
assertTrue(propDefs.containsKey(result));
// Check the property definition
PropertyDefinition propDef = propDefs.get(result);
assertNotNull(propDef);
assertNotNull(propDef);
assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName());
assertEquals("Description", propDef.getDescription());
assertEquals("Label", propDef.getTitle());
assertEquals("Description", propDef.getDescription(dictionaryService));
assertEquals("Label", propDef.getTitle(dictionaryService));
}
});
});
}
public void testUseCustomProperty() throws Exception
{
// Create custom property on type and aspect
@@ -470,29 +470,29 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
@Override
public QName run() throws Exception
{
adminService.makeCustomisable(TYPE_CUSTOM_TYPE);
adminService.makeCustomisable(TYPE_CUSTOM_TYPE);
madeCustomisable.add(TYPE_CUSTOM_TYPE);
adminService.addCustomPropertyDefinition(
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"),
TYPE_CUSTOM_TYPE,
"Label",
DataTypeDefinition.TEXT,
"Title",
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"),
TYPE_CUSTOM_TYPE,
"Label",
DataTypeDefinition.TEXT,
"Title",
"Description");
adminService.makeCustomisable(ASPECT_CUSTOM_ASPECT);
adminService.makeCustomisable(ASPECT_CUSTOM_ASPECT);
madeCustomisable.add(ASPECT_CUSTOM_ASPECT);
adminService.addCustomPropertyDefinition(
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"),
ASPECT_CUSTOM_ASPECT,
"Label",
DataTypeDefinition.TEXT,
"Title",
"Description");
QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"),
ASPECT_CUSTOM_ASPECT,
"Label",
DataTypeDefinition.TEXT,
"Title",
"Description");
return null;
}
});
// Create nodes using custom type and aspect
doTestInTransaction(new Test<QName>()
{
@@ -500,36 +500,36 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
public QName run() throws Exception
{
NodeRef customInstance1 = nodeService.createNode(
folder,
ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance1"),
folder,
ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance1"),
TYPE_CUSTOM_TYPE).getChildRef();
NodeRef customInstance2 = nodeService.createNode(
folder,
ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance2"),
folder,
ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance2"),
TYPE_CONTENT).getChildRef();
nodeService.addAspect(customInstance2, ASPECT_CUSTOM_ASPECT, null);
// Assert that both instances have the custom aspects applied
assertTrue(nodeService.hasAspect(customInstance1, QName.createQName(RM_CUSTOM_URI, "rmtcustomTypeCustomProperties")));
assertTrue(nodeService.hasAspect(customInstance2, QName.createQName(RM_CUSTOM_URI, "rmtcustomAspectCustomProperties")));
// Remove the custom aspect
nodeService.removeAspect(customInstance2, ASPECT_CUSTOM_ASPECT);
// Assert the custom property aspect is no longer applied applied
assertTrue(nodeService.hasAspect(customInstance1, QName.createQName(RM_CUSTOM_URI, "rmtcustomTypeCustomProperties")));
assertFalse(nodeService.hasAspect(customInstance2, QName.createQName(RM_CUSTOM_URI, "rmtcustomAspectCustomProperties")));
return null;
}
}, AuthenticationUtil.getSystemUserName());
}, AuthenticationUtil.getSystemUserName());
}
public void testCreateAndUseCustomChildReference() throws Exception
{
{
long now = System.currentTimeMillis();
createAndUseCustomReference(CustomReferenceType.PARENT_CHILD, null, "superseded" + now, "superseding" + now);
}
@@ -539,7 +539,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
long now = System.currentTimeMillis();
createAndUseCustomReference(CustomReferenceType.BIDIRECTIONAL, "supporting" + now, null, null);
}
private void createAndUseCustomReference(final CustomReferenceType refType, final String label, final String source, final String target) throws Exception
{
final NodeRef testRecord1 = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
@@ -548,16 +548,16 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
{
NodeRef result = utils.createRecord(rmFolder, "testRecordA" + System.currentTimeMillis());
return result;
}
});
}
});
final NodeRef testRecord2 = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Throwable
{
NodeRef result = utils.createRecord(rmFolder, "testRecordB" + System.currentTimeMillis());
return result;
}
});
}
});
final QName generatedQName = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<QName>()
{
@@ -586,11 +586,11 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
}
System.out.println("Creating new " + refType + " reference definition: " + qNameResult);
System.out.println(" params- label: '" + label + "' source: '" + source + "' target: '" + target + "'");
return qNameResult;
}
});
}
});
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
@@ -601,11 +601,11 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
assertNotNull("Custom reference definition from adminService was null.", retrievedRefDefn);
assertEquals(generatedQName, retrievedRefDefn.getName());
assertEquals(refType.equals(CustomReferenceType.PARENT_CHILD), retrievedRefDefn.isChild());
// Now we need to use the custom reference.
// So we apply the aspect containing it to our test records.
nodeService.addAspect(testRecord1, ASPECT_CUSTOM_ASSOCIATIONS, null);
QName assocsAspectQName = QName.createQName("rmc:customAssocs", namespaceService);
nodeService.addAspect(testRecord1, assocsAspectQName, null);
@@ -618,9 +618,9 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
nodeService.createAssociation(testRecord1, testRecord2, generatedQName);
}
return null;
}
});
}
});
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
@@ -628,7 +628,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
// Read back the reference value to make sure it was correctly applied.
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(testRecord1);
List<AssociationRef> retrievedAssocs = nodeService.getTargetAssocs(testRecord1, RegexQNamePattern.MATCH_ALL);
Object newlyAddedRef = null;
if (CustomReferenceType.PARENT_CHILD.equals(refType))
{
@@ -647,7 +647,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
}
}
assertNotNull("newlyAddedRef was null.", newlyAddedRef);
// Check that the reference has appeared in the data dictionary
AspectDefinition customAssocsAspect = dictionaryService.getAspect(ASPECT_CUSTOM_ASSOCIATIONS);
assertNotNull(customAssocsAspect);
@@ -662,10 +662,10 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
customAssocsAspect.getAssociations().get(generatedQName));
}
return null;
}
});
}
});
}
public void testGetAllProperties()
{
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
@@ -678,17 +678,17 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
for (QName prop : props.keySet())
{
System.out.println(" - " + prop.toString());
String propId = props.get(prop).getTitle();
String propId = props.get(prop).getTitle(dictionaryService);
assertNotNull("null client-id for " + prop, propId);
System.out.println(" " + propId);
}
}
return null;
}
});
}
});
}
public void testGetAllReferences()
{
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
@@ -701,15 +701,15 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
for (QName reference : references.keySet())
{
System.out.println(" - " + reference.toString());
System.out.println(" " + references.get(reference).getTitle());
System.out.println(" " + references.get(reference).getTitle(dictionaryService));
}
return null;
}
});
}
});
}
public void testGetAllConstraints()
{
{
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
@@ -720,18 +720,18 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
for (ConstraintDefinition constraint : constraints)
{
System.out.println(" - " + constraint.getName());
System.out.println(" " + constraint.getTitle());
System.out.println(" " + constraint.getTitle(dictionaryService));
}
return null;
}
});
}
});
}
private boolean beforeMarker = false;
private boolean onMarker = false;
@SuppressWarnings("unused")
private boolean inTest = false;
public void testCreateReference() throws Exception
{
inTest = true;
@@ -746,44 +746,44 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
NodeRef rec2 = utils.createRecord(rmFolder, "testRecordB" + System.currentTimeMillis());
Pair<NodeRef, NodeRef> result = new Pair<NodeRef, NodeRef>(rec1, rec2);
return result;
}
}
});
final NodeRef testRecord1 = testRecords.getFirst();
final NodeRef testRecord2 = testRecords.getSecond();
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
utils.declareRecord(testRecord1);
utils.declareRecord(testRecord2);
policyComponent.bindClassBehaviour(
RecordsManagementPolicies.BEFORE_CREATE_REFERENCE,
this,
RecordsManagementPolicies.BEFORE_CREATE_REFERENCE,
this,
new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "beforeCreateReference", NotificationFrequency.EVERY_EVENT));
policyComponent.bindClassBehaviour(
RecordsManagementPolicies.ON_CREATE_REFERENCE,
this,
RecordsManagementPolicies.ON_CREATE_REFERENCE,
this,
new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "onCreateReference", NotificationFrequency.EVERY_EVENT));
assertFalse(beforeMarker);
assertFalse(onMarker);
adminService.addCustomReference(testRecord1, testRecord2, CUSTOM_REF_VERSIONS);
assertTrue(beforeMarker);
assertTrue(onMarker);
return null;
}
});
}
});
}
finally
{
inTest = false;
}
}
}
public void beforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
{
beforeMarker = true;
@@ -793,7 +793,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
{
onMarker = true;
}
public void testCreateCustomConstraints() throws Exception
{
final int beforeCnt =
@@ -804,65 +804,65 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
List<ConstraintDefinition> result = adminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL);
assertNotNull(result);
return result.size();
}
});
}
});
final String conTitle = "test title - "+testRunID;
final List<String> allowedValues = new ArrayList<String>(3);
allowedValues.add("RED");
allowedValues.add("AMBER");
allowedValues.add("GREEN");
final QName testCon = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<QName>()
{
public QName execute() throws Throwable
{
String conLocalName = "test-"+testRunID;
final QName result = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, conLocalName);
adminService.addCustomConstraintDefinition(result, conTitle, true, allowedValues, MatchLogic.AND);
return result;
}
});
}
});
// Set the current security context as System - to see allowed values (unless caveat config is also updated for admin)
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
List<ConstraintDefinition> customConstraintDefs = adminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL);
assertEquals(beforeCnt+1, customConstraintDefs.size());
boolean found = false;
for (ConstraintDefinition conDef : customConstraintDefs)
{
if (conDef.getName().equals(testCon))
{
assertEquals(conTitle, conDef.getTitle());
assertEquals(conTitle, conDef.getTitle(dictionaryService));
Constraint con = conDef.getConstraint();
assertTrue(con instanceof RMListOfValuesConstraint);
assertEquals("LIST", ((RMListOfValuesConstraint)con).getType());
assertEquals(3, ((RMListOfValuesConstraint)con).getAllowedValues().size());
found = true;
break;
}
}
assertTrue(found);
return null;
}
});
}
});
// Set the current security context as admin
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
@@ -870,55 +870,55 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
allowedValues.clear();
allowedValues.add("RED");
allowedValues.add("YELLOW");
adminService.changeCustomConstraintValues(testCon, allowedValues);
return null;
}
});
}
});
// Set the current security context as System - to see allowed values (unless caveat config is also updated for admin)
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
List<ConstraintDefinition> customConstraintDefs = adminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL);
assertEquals(beforeCnt+1, customConstraintDefs.size());
boolean found = false;
for (ConstraintDefinition conDef : customConstraintDefs)
{
if (conDef.getName().equals(testCon))
{
assertEquals(conTitle, conDef.getTitle());
assertEquals(conTitle, conDef.getTitle(dictionaryService));
Constraint con = conDef.getConstraint();
assertTrue(con instanceof RMListOfValuesConstraint);
assertEquals("LIST", ((RMListOfValuesConstraint)con).getType());
assertEquals(2, ((RMListOfValuesConstraint)con).getAllowedValues().size());
found = true;
break;
}
}
assertTrue(found);
return null;
}
});
}
});
// Set the current security context as admin
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
// Add custom property to record with test constraint
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
String propLocalName = "myProp-"+testRunID;
QName dataType = DataTypeDefinition.TEXT;
String propTitle = "My property title";
String description = "My property description";
@@ -926,11 +926,11 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
boolean multiValued = false;
boolean mandatory = false;
boolean isProtected = false;
QName propName = adminService.addCustomPropertyDefinition(null, ASPECT_RECORD, propLocalName, dataType, propTitle, description, defaultValue, multiValued, mandatory, isProtected, testCon);
createdCustomProperties.add(propName);
return null;
}
});
}
});
}
}