use of org.alfresco.repo.policy.JavaBehaviour in project records-management by Alfresco.
the class RecordsManagementAdminServiceImplTest method testCreateReference.
public void testCreateReference() throws Exception {
inTest = true;
try {
// Create the necessary test objects in the db: two records.
final Pair<NodeRef, NodeRef> testRecords = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Pair<NodeRef, NodeRef>>() {
public Pair<NodeRef, NodeRef> execute() throws Throwable {
NodeRef rec1 = utils.createRecord(rmFolder, "testRecordA" + System.currentTimeMillis());
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.completeRecord(testRecord1);
utils.completeRecord(testRecord2);
policyComponent.bindClassBehaviour(RecordsManagementPolicies.BEFORE_CREATE_REFERENCE, this, new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "beforeCreateReference", NotificationFrequency.EVERY_EVENT));
policyComponent.bindClassBehaviour(RecordsManagementPolicies.ON_CREATE_REFERENCE, this, new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "onCreateReference", NotificationFrequency.EVERY_EVENT));
assertFalse(beforeMarker);
assertFalse(onMarker);
relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), testRecord1, testRecord2);
assertTrue(beforeMarker);
assertTrue(onMarker);
return null;
}
});
} finally {
inTest = false;
}
}
use of org.alfresco.repo.policy.JavaBehaviour in project records-management by Alfresco.
the class RecordsManagementActionServiceImplTest method executionImpl.
private void executionImpl() {
inTest = true;
try {
policyComponent.bindClassBehaviour(RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION, this, new JavaBehaviour(this, "beforeRMActionExecution", NotificationFrequency.EVERY_EVENT));
policyComponent.bindClassBehaviour(RecordsManagementPolicies.ON_RM_ACTION_EXECUTION, this, new JavaBehaviour(this, "onRMActionExecution", NotificationFrequency.EVERY_EVENT));
assertFalse(beforeMarker);
assertFalse(onMarker);
assertFalse(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD));
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(TestAction.PARAM, TestAction.PARAM_VALUE);
this.rmActionService.executeRecordsManagementAction(this.nodeRef, TestAction.NAME, params);
assertTrue(beforeMarker);
assertTrue(onMarker);
assertTrue(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD));
} finally {
inTest = false;
}
}
Aggregations