mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fixed one of the failing tests for rules coverage:
- The test model didn't allow multiple values for the category property. - The setting of the category in the action puts a single value if one doesn't exist, or changes the value to a collection if a category already exists. This is true even if the category is exactly the same. I have **NOT** managed to fix the 'testInboundRuleType' because it would appear that the test action evaluation is being done with a NoConditionEvaluator. The test checks to see that the action is not executed for an empty content node. It might be a side-effect of the parent node update policy ... but I can't see why. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5991 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -142,6 +142,17 @@ public class ActionImpl extends ParameterizedItemImpl
|
|||||||
this.actionDefinitionName = actionDefinitionName;
|
this.actionDefinitionName = actionDefinitionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Action")
|
||||||
|
.append("[ id=").append(getId())
|
||||||
|
.append(", node=").append(nodeRef)
|
||||||
|
.append(" ]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.action.Action#getTitle()
|
* @see org.alfresco.service.cmr.action.Action#getTitle()
|
||||||
*/
|
*/
|
||||||
|
@@ -27,6 +27,7 @@ package org.alfresco.repo.action;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
|
import org.alfresco.error.StackTraceUtil;
|
||||||
import org.alfresco.repo.rule.RuleServiceImpl;
|
import org.alfresco.repo.rule.RuleServiceImpl;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
@@ -116,6 +117,22 @@ public class AsynchronousActionExecutionQueueImpl implements AsynchronousActionE
|
|||||||
actionChain,
|
actionChain,
|
||||||
executedRules);
|
executedRules);
|
||||||
threadPoolExecutor.execute(runnable);
|
threadPoolExecutor.execute(runnable);
|
||||||
|
// Done
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
// get the stack trace
|
||||||
|
Exception e = new Exception();
|
||||||
|
e.fillInStackTrace();
|
||||||
|
StackTraceElement[] trace = e.getStackTrace();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("\n")
|
||||||
|
.append("Placed action on execution queue: \n")
|
||||||
|
.append(" Action: " + action);
|
||||||
|
String msg = sb.toString();
|
||||||
|
sb = new StringBuilder();
|
||||||
|
StackTraceUtil.buildStackTrace(msg, trace, sb, -1);
|
||||||
|
logger.debug(sb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -27,6 +27,7 @@ package org.alfresco.repo.rule;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -60,8 +61,7 @@ import org.alfresco.repo.dictionary.M2Aspect;
|
|||||||
import org.alfresco.repo.dictionary.M2Model;
|
import org.alfresco.repo.dictionary.M2Model;
|
||||||
import org.alfresco.repo.dictionary.M2Property;
|
import org.alfresco.repo.dictionary.M2Property;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.transaction.TransactionUtil;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
|
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ActionCondition;
|
import org.alfresco.service.cmr.action.ActionCondition;
|
||||||
@@ -160,15 +160,15 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
|
|
||||||
//authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
//authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||||
//authenticationComponent.setSystemUserAsCurrentUser();
|
//authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
TransactionWork<Object> setUserWork = new TransactionWork<Object>()
|
RetryingTransactionCallback<Object> setUserCallback = new RetryingTransactionCallback<Object>()
|
||||||
{
|
{
|
||||||
public Object doWork() throws Exception
|
public Object execute() throws Exception
|
||||||
{
|
{
|
||||||
authenticationComponent.setCurrentUser("admin");
|
authenticationComponent.setCurrentUser("admin");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TransactionUtil.executeInUserTransaction(transactionService, setUserWork);
|
transactionService.getRetryingTransactionHelper().doInTransaction(setUserCallback);
|
||||||
|
|
||||||
this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
|
this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
|
||||||
this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);
|
this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);
|
||||||
@@ -218,7 +218,7 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
genCatProp.setIndexed(true);
|
genCatProp.setIndexed(true);
|
||||||
genCatProp.setIndexedAtomically(true);
|
genCatProp.setIndexedAtomically(true);
|
||||||
genCatProp.setMandatory(true);
|
genCatProp.setMandatory(true);
|
||||||
genCatProp.setMultiValued(false);
|
genCatProp.setMultiValued(true);
|
||||||
genCatProp.setStoredInIndex(true);
|
genCatProp.setStoredInIndex(true);
|
||||||
genCatProp.setTokenisedInIndex(true);
|
genCatProp.setTokenisedInIndex(true);
|
||||||
genCatProp.setType("d:" + DataTypeDefinition.CATEGORY.getLocalName());
|
genCatProp.setType("d:" + DataTypeDefinition.CATEGORY.getLocalName());
|
||||||
@@ -246,11 +246,10 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public void testAsyncRuleExecution()
|
public void testAsyncRuleExecution()
|
||||||
{
|
{
|
||||||
final NodeRef newNodeRef = TransactionUtil.executeInUserTransaction(
|
final NodeRef newNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||||
this.transactionService,
|
new RetryingTransactionCallback<NodeRef>()
|
||||||
new TransactionUtil.TransactionWork<NodeRef>()
|
|
||||||
{
|
{
|
||||||
public NodeRef doWork()
|
public NodeRef execute()
|
||||||
{
|
{
|
||||||
RuleServiceCoverageTest.this.nodeService.addAspect(
|
RuleServiceCoverageTest.this.nodeService.addAspect(
|
||||||
RuleServiceCoverageTest.this.nodeRef,
|
RuleServiceCoverageTest.this.nodeRef,
|
||||||
@@ -677,9 +676,11 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
addContentToNode(newNodeRef2);
|
addContentToNode(newNodeRef2);
|
||||||
|
|
||||||
// Check that the category value has been set
|
// Check that the category value has been set
|
||||||
NodeRef setValue = (NodeRef)this.nodeService.getProperty(newNodeRef2, CAT_PROP_QNAME);
|
// It has been declared as a multi-value property, so we expect that here
|
||||||
|
Collection<NodeRef> setValue = (Collection<NodeRef>) this.nodeService.getProperty(newNodeRef2, CAT_PROP_QNAME);
|
||||||
assertNotNull(setValue);
|
assertNotNull(setValue);
|
||||||
assertEquals(this.catROne, setValue);
|
assertEquals(1, setValue.size());
|
||||||
|
assertEquals(this.catROne, setValue.toArray()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1078,11 +1079,10 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
|
|
||||||
this.ruleService.saveRule(this.nodeRef, rule);
|
this.ruleService.saveRule(this.nodeRef, rule);
|
||||||
|
|
||||||
List<NodeRef> list = TransactionUtil.executeInUserTransaction(
|
List<NodeRef> list = transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||||
this.transactionService,
|
new RetryingTransactionCallback<List<NodeRef>>()
|
||||||
new TransactionUtil.TransactionWork<List<NodeRef>>()
|
|
||||||
{
|
{
|
||||||
public List<NodeRef> doWork()
|
public List<NodeRef> execute()
|
||||||
{
|
{
|
||||||
// Create a new node and check-it out
|
// Create a new node and check-it out
|
||||||
NodeRef newNodeRef = RuleServiceCoverageTest.this.nodeService.createNode(
|
NodeRef newNodeRef = RuleServiceCoverageTest.this.nodeService.createNode(
|
||||||
@@ -1459,9 +1459,9 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
this.nodeService.setProperty(nodeRef2, ContentModel.PROP_NAME, "testName2");
|
this.nodeService.setProperty(nodeRef2, ContentModel.PROP_NAME, "testName2");
|
||||||
assertTrue(this.nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
|
||||||
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>()
|
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
|
||||||
{
|
{
|
||||||
public Object doWork() throws Exception
|
public Object execute() throws Exception
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||||
props.put(ContentModel.PROP_NAME, "testName");
|
props.put(ContentModel.PROP_NAME, "testName");
|
||||||
|
Reference in New Issue
Block a user