AnsweredAssumed Answered

Does 'taskVariableValueEquals' method does not work?

Question asked by aitor on Oct 10, 2013
Latest reply on Oct 11, 2013 by aitor
Tested in version 5.13:

My BPMN Process (simpleprocess.bpmn):


<?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: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="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="UserTask1"></userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <userTask id="usertask2" name="UserTask2"></userTask>
    <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
  </process>
</definitions>


My JUnit Test:

public class ProcessTestMyProcess {
   private String filename = "simpleprocess.bpmn";

   @Rule
   public ActivitiRule activitiRule = new ActivitiRule();

   @Test
   public void startProcess() throws Exception {
      RepositoryService repositoryService = activitiRule.getRepositoryService();
      repositoryService.createDeployment().addInputStream("myProcess.bpmn20.xml",
            new FileInputStream(filename)).deploy();
      RuntimeService runtimeService = activitiRule.getRuntimeService();
      Map<String, Object> variableMap = new HashMap<String, Object>();
      variableMap.put("name", "Activiti");
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess", variableMap);
      assertNotNull(processInstance.getId());
      System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
      
      // Get Task
      TaskService taskService = activitiRule.getTaskService();
      Task task = taskService.createTaskQuery().taskUnassigned().singleResult();
      assertNotNull(task.getId());
      System.out.println("Task 1 id " + task.getId());
      
      // Set Variable
      taskService.setVariable(task.getId(), "var_name", "var_value");
      
      // Get Task by variable
      Task task2 = taskService.createTaskQuery().taskVariableValueEquals("var_name", "var_value").singleResult();
      assertNotNull(task2.getId());
      System.out.println("Task 2 id " + task2.getId());
   }
}


The result is FAIL!!!???

Thanks.

Outcomes