AnsweredAssumed Answered

taskService.createTaskQuery() not returning values in unit test

Question asked by rogerparkinson on Apr 13, 2015
Latest reply on Apr 14, 2015 by rogerparkinson
Here's a simple unit test snippet:

public class ProcessTestMyProcess {

   private String filename = "/home/roger/activiti/ghi-core-processes/NMC.bpmn";

   public ActivitiRule activitiRule = new ActivitiRule();

   public void startProcess() throws Exception {
      RepositoryService repositoryService = activitiRule.getRepositoryService();
            new FileInputStream(filename)).deploy();
      RuntimeService runtimeService = activitiRule.getRuntimeService();
      TaskService taskService = activitiRule.getTaskService();
      Map<String, Object> variableMap = new HashMap<String, Object>();
      variableMap.put("name", "Activiti");
      variableMap.put("claimId", "test");
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess", variableMap);
      final String pid = processInstance.getId();
      List<String> activityIds = runtimeService.getActiveActivityIds(pid);
      assertEquals("reviewClaim", activityIds.get(0));
      Task task = taskService.createTaskQuery().processInstanceId(pid).singleResult();
That last assert fails, variable task is null.
I expected it to find a task corresponding to my 'reviewClaim' userTask:

    <userTask id="reviewClaim" name="Review Claim" activiti:async="true" activiti:assignee="kermit">
        <activiti:formProperty id="claimId" name="Claim" type="long" writable="false" required="true"></activiti:formProperty>

I tried
Task task = taskService.createTaskQuery().taskAssignee("kermit").singleResult();
but got the same result.
The only odd thing I can think of about the process it it has a serviceTask executed first, then an exclusive gateway and then this userTask. But that doesn't seem so very odd. Based on the contents of activityIds it clearly went to the right userTask, but I need the Task to do the next step ie

What have I misunderstood here?