cancel
Showing results for 
Search instead for 
Did you mean: 

Unit tests with variable into workflow

marcantoine
Champ in-the-making
Champ in-the-making
Hi,

I'm based on unit tests located here:
https://forums.activiti.org/content/sticky-how-write-unit-test (and the source code repository).

I'll try to add some unit tests on my extensions of Service Task wrote in Java.
To test all configurations I need to launch this simplest workflow (with the simple activity), and pass parameters on the launch of the instance.
In my JavaDelegation class, I don't have correct values after get expression content. I get ${type} instead of the input value I passed to start the workflow.
Is it a bug ? because it work fine on a deployed instance of Activiti.
Do you have an issue for that ?

Thank,
Marc-Antoine


<?xml version="1.0" encoding="UTF-8"?>
<definitions
   xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:activiti="http://activiti.org/bpmn"
   xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
   xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
   xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
   typeLanguage="http://www.w3.org/2001/XMLSchema"
   expressionLanguage="http://www.w3.org/1999/XPath"
   targetNamespace="http://www.activiti.org/test">
<process id="workflowTest">
    <startEvent id="startevent1" name="Start" activiti:formKey="startForm">
     </startEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <serviceTask id="servicetask1" name="Test Extension" activiti:class="com.arkena.ConnectorJavaDelegation" activiti:extensionId="com.arkena.ConnectorDownloadTask">
      <extensionElements>
        <activiti:field name="type">
          <activiti:string>${type}</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
</process>
</definitions>

1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Marc-Antoine,

have a look on an example:
org.activiti.engine.test.bpmn.servicetask.ServiceTaskVariablesTest
in activiti source

Regards
Martin