Hello,

I was playing around learning jBPM and wrote a simple test program that gave me 
unexpected results.  Process def and test code given below, but here's the 
problem in a nutshell.  I have a task node "Collect Canditate Info" with 1 task 
that when complete transitions the node to the next task node "Check 
Background" which has  2 tasks.  My sample program walks the process and prints 
the number and names of the tasks for these two nodes.  The first node, Collect 
Candidate Info, is fine--1 task correctly named is shown.

But... after successfully transitioning to "Check Background" my program shows 
3 tasks--the one left over from the previous node plus the 2 I expect to see in 
the now-current node.  For some reason the previous task nodes tasks aren't 
getting cleared out.

I would expect that after moving to the next node the previous node's tasks 
should no longer be visible, or at least certainly not mixed in with the 
current nodes tasks.

Am I doing something wrong, or is my expectation of correct operation 
incomplete, or is this just an 'ol fashion bug?

I'm using the jbpm starters kit 3.1.2.

Thanks in advance for any replies!
Greg



Here's the process definition:

<?xml version="1.0" encoding="UTF-8"?>

<process-definition
  xmlns="urn:jbpm.org:jpdl-3.1"  name="Hire New Employee">
   
   <start-state name="start">
      
   </start-state>
   <task-node name="Check Background">
      
      
      
   </task-node>
   <task-node name="Collect Candidate Info">
      
      
   </task-node>
   <task-node name="Interview Candidate">
      
   </task-node>
   
      
      
      
      
   
   <end-state name="Hire"></end-state>
   <end-state name="Pass"></end-state>
</process-definition>


Here's the test program:

package com.sample;

import java.io.FileInputStream;
import junit.framework.TestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.taskmgmt.exe.TaskInstance;

public class GregsTest extends TestCase {

        public void testSimpleProcess() throws Exception {

                // Extract a process definition from the processdefinition.xml 
file.
                FileInputStream fis = new FileInputStream("processes/Hire New 
Employee/processdefinition.xml");
                ProcessDefinition processDefinition = 
ProcessDefinition.parseXmlInputStream(fis);
                assertNotNull("Definition should not be null", 
processDefinition);

                // Create an instance of the process definition.
                ProcessInstance instance = new 
ProcessInstance(processDefinition);
                assertEquals(
                                "Instance is in start state", 
                                instance.getRootToken().getNode().getName(), 
                                "start");
                assertNull(
                                "Message variable should not exist yet", 
                                
instance.getContextInstance().getVariable("message"));

                // Move the process instance from its start state to the first 
state.
                // The configured action should execute and the appropriate 
message
                // should appear in the message process variable.
                instance.signal();
                assertEquals(
                                "Collecting candidate information", 
                                instance.getRootToken().getNode().getName(), 
                                "Collect Candidate Info");

                // Move the process instance to the end state. The configured 
action 
                // should execute again. The message variable contains a new 
value.
                System.out.println("YYY: Number of Tasks in node is " 
                                + 
instance.getTaskMgmtInstance().getTaskInstances().size());
                TaskInstance taskInstance = (TaskInstance)  
              
instance.getTaskMgmtInstance().getTaskInstances().iterator().next();
        
                System.out.println("ZZZ: Node Now is "+ 
instance.getRootToken().getNode().getName());
                System.out.println("ZZZ: Task now is "+taskInstance.getName());
                
                taskInstance.end();
                System.out.println("ZZZ: Node Now is "+ 
instance.getRootToken().getNode().getName());

                assertEquals(
                                "Instance is in Check Background state", 
                                instance.getRootToken().getNode().getName(), 
                                "Check Background");

                System.out.println("YYY: Number of Tasks in node is " 
                                + 
instance.getTaskMgmtInstance().getTaskInstances().size());
                java.util.Iterator taskScan = 
instance.getTaskMgmtInstance().getTaskInstances().iterator();
                while(taskScan.hasNext()) {
                        TaskInstance aTask = (TaskInstance) taskScan.next();
//                      System.out.println("ZZZ: Node Now is "+ 
instance.getRootToken().getNode().getName());
                        System.out.println("ZZZ: Task now is "+aTask.getName());
                        //aTask.end();
                }
        }

}

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3997150#3997150

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3997150
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to