3 Replies Latest reply on Feb 15, 2010 5:47 AM by Sebastian Schneider

    Question on TaskQuery

    ben d Newbie

      Hi there,


      I've just run the following code :




      I'd expect this code to return only tasks that are associated to the given processInstanceId and whose name are xxx. But I get all sorts of tasks; I mean tasks whose names differ from xxx. Is that the expected behaviour ?




        • 1. Re: Question on TaskQuery
          Sebastian Schneider Master
          I suppose it's not. Can you make a test case which demonstrates the problem? Then we can check and if necessary you can create a JIRA issue.
          • 2. Re: Question on TaskQuery
            ben d Newbie

            Hi there,


            I'm using the following jpdl file:


            <?xml version="1.0" encoding="UTF-8"?>
            <process name="TestTaskProcess" xmlns="http://jbpm.org/4.3/jpdl">
                 <start g="9,20,48,48">
                      <transition to="Task1" />
                 <task g="159,16,127,52" name="Task1">
                      <transition to="Task2" name="t" />
                 <task g="159,120,127,52" name="Task2">
                      <transition to="Task3" name="t" />
                 <task g="161,231,124,52" name="Task3">
                      <transition to="end" name="t" />
                 <end g="371,233,48,48" name="end" />


            And my test case:


                      ProcessEngine processEngine = new Configuration().buildProcessEngine();
                      RepositoryService repositoryService = processEngine.getRepositoryService();
                      TaskService taskService = processEngine.getTaskService();
                      ExecutionService executionService = processEngine.getExecutionService();
                      NewDeployment deployment = repositoryService.createDeployment().addResourceFromClasspath(
                      ProcessInstance processInstance = executionService
                      // Move to Task2
                      String activeExecutionId = processInstance.findActiveExecutionIn("Task1").getId();
                      ProcessInstance instance = executionService.signalExecutionById(activeExecutionId, "t");
                      TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(
                      // --> [Task(Task1), Task(Task2)]


            And the outcome is [Task(Task1), Task(Task2)]. Which means I get two tasks instances even though I restricted my query on the activity name.


            Maybe this is due to the way I "navigate" from one task to another.




            • 3. Re: Question on TaskQuery
              Sebastian Schneider Master

              It is due to your strange way of using tasks. What are you trying to achieve? Assign the tasks to somebody and complete them. After completion of a task the execution will move on to the next one. In this case the TaskQuery is working fine and as expected.


              Please note: Creating unit-tests extending JbpmTestcase is the preferred way of supplying test cases. It saves you a lot of code and makes testing easier.