AnsweredAssumed Answered

Unit Test cases for Custom Java Service Task

Question asked by babjikundateeri on Aug 29, 2016
Latest reply on Aug 30, 2016 by babjikundateeri

I am new to activiti.

I am not able to figure out the way to write test cases for custom java delegate classes.
below is my test code snippet,
public class WorkFlowTest {

    public ActivitiRule activitiRule = new ActivitiRule();

    @Deployment(resources = {"testemailflow.bpmn20.xml"})
    public void activitiTest() {
        Map<String, Object>  variables = new HashMap<>();
        RuntimeService runtimeService = activitiRule.getRuntimeService();
        runtimeService.startProcessInstanceByKey("testemailflow", variables);
and my service task is as below
<serviceTask id="sid-3E402CB5-51C0-4BB9-9483-941C0BBB7128" name="contact picker" activiti:delegateExpression="${contactPickerTaskDelegation}">
                <activiti:field name="contactPickerRuleId">
my delegate code is as below
public class ContactPickerTaskDelegation implements JavaDelegate {
   private Expression contactPickerRuleId;

    public void execute(DelegateExecution delegateExecution) throws Exception {
         LOGGER.debug("contactPickerRuleId " + contactPickerRuleId.getValue(delegateExecution).toString());
         List<Contact> contacts;  // doing something to get contacts
         delegateExecution.setVariable("contacts", contacts);
while running the test case i' end-up with the exception like below
org.activiti.engine.ActivitiException: Unknown property used in expression: ${contactPickerTaskDelegation}

   at org.activiti.engine.impl.el.JuelExpression.getValue(
   at org.activiti.engine.impl.bpmn.helper.DelegateExpressionUtil.resolveDelegateExpression(
   at org.activiti.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior.execute(
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(

My Application is using `spring-boot`.

Thanks in advance.