cancel
Showing results for 
Search instead for 
Did you mean: 

Unit testing Workflow with Alfresco Mail Task

gribas
Champ in-the-making
Champ in-the-making
Hi folks,

I'm trying to do some unit tests to my workflow definition and I have some problems that maybe you can help me.

The first error is when I dessign the workflow with activiti designer it puts a task like this:


<serviceTask id="alfrescoMailtask1" name="Mail Task" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
   <extensionElements>
      <activiti:field name="script">
         <activiti:string>
            var mail = actions.create("mail");
            mail.execute(bpm_package);
         </activiti:string>
      </activiti:field>
      <activiti:field name="mail.parameters.to">
         <activiti:string>some@email.com</activiti:string>
      </activiti:field>
      <activiti:field name="mail.parameters.subject">
         <activiti:expression>Time Expired</activiti:expression>
      </activiti:field>
      <activiti:field name="mail.parameters.text">
         <activiti:expression>Time Expired</activiti:expression>
      </activiti:field>
   </extensionElements>
</serviceTask>


But when I run my unit test I got this exception:

2014-01-29 09:53:47,775  ERROR [impl.jobexecutor.TimerExecuteNestedActivityJobHandler] [pool-1-thread-1] exception during timer execution
org.activiti.engine.ActivitiIllegalArgumentException: Field definition uses unexisting field 'mail.parameters.to' on class org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.applyFieldDeclaration(ClassDelegate.java:193)
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.applyFieldDeclaration(ClassDelegate.java:171)
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.instantiateDelegate(ClassDelegate.java:164)
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.getActivityBehaviorInstance(ClassDelegate.java:136)
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:113)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:87)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at
…..
I solved this one removing the activiti fields and adding into the script part.

But when I tried to run it again: I got this exception

2014-01-29 09:55:51,316  ERROR [impl.jobexecutor.TimerExecuteNestedActivityJobHandler] [pool-1-thread-1] exception during timer execution
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'services' is defined
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1094)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:276)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
   at org.activiti.engine.impl.cfg.SpringBeanFactoryProxyMap.get(SpringBeanFactoryProxyMap.java:39)
   at org.alfresco.repo.workflow.activiti.script.ActivitiScriptBase.getServiceRegistry(ActivitiScriptBase.java:126)
   at org.alfresco.repo.workflow.activiti.script.DelegateExecutionScriptBase.checkFullyAuthenticatedUser(DelegateExecutionScriptBase.java:134)
   at org.alfresco.repo.workflow.activiti.script.DelegateExecutionScriptBase.runScript(DelegateExecutionScriptBase.java:60)
   at org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate.execute(AlfrescoScriptDelegate.java:43)
   at org.activiti.engine.impl.delegate.JavaDelegateInvocation.invoke(JavaDelegateInvocation.java:34)
   at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)
   at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)
   at org.activiti.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:49)
   at org.activiti.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:40)
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:116)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:87)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at
……….

Any Idea how I can autowire this services bean?

Thanks,

Regards,
Gerard.
1 REPLY 1

pnature
Star Contributor
Star Contributor

Hi. I have stumbled this problem too. Any solution?