[JBoss jBPM] - Re: process versioning + swimlane with pooledActors
by yoyoyoyo
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process-definition
| xmlns="urn:jbpm.org:jpdl-3.1" name="returngoods.swimlane-pooled-actors">
|
| <swimlane name="Shipping">
| <assignment pooled-actors="grover, yoyo"></assignment>
| </swimlane>
| <swimlane name="Sales">
| <assignment pooled-actors="ernie, yoyo"></assignment>
| </swimlane>
| <swimlane name="Accounting">
| <assignment pooled-actors="bert, yoyo"></assignment>
| </swimlane>
|
| <start-state name="Ship Order Return">
| <task name="Send Item">
| <controller>
| <variable name="tracking number" access="read,write,required"></variable>
| </controller>
| </task>
| <transition name="Shipping" to="Receive Return"></transition>
| </start-state>
|
| <task-node name="Receive Return">
| <task name="Receive Item" swimlane="Shipping">
| <controller>
| <variable name="tracking number" access="read"></variable>
| <variable name="received date" access="read,write,required"></variable>
| </controller>
| </task>
| <transition name="Process Return" to="fork 1"></transition>
| </task-node>
|
| <fork name="fork 1">
| <transition name="Ordering" to="Update Order"></transition>
| <transition name="Accounting" to="Return Money"></transition>
| </fork>
|
| <task-node name="Update Order">
| <task name="Send Updated Order" swimlane="Sales">
| <controller>
| <variable name="address" access="read,write,required"></variable>
| </controller>
| </task>
| <transition name="" to="join1"></transition>
| </task-node>
|
| <task-node name="Return Money">
| <task name="Update Books" swimlane="Accounting">
| <controller>
| <variable name="amount" access="read,write,required"></variable>
| </controller>
| </task>
| <transition name="" to="join1"></transition>
| </task-node>
|
| <join name="join1">
| <transition name="" to="Process End"></transition>
| </join>
|
| <end-state name="Process End"></end-state>
|
| </process-definition>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036909#4036909
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036909
19 years
[JBoss jBPM] - Re: process versioning + swimlane with pooledActors
by yoyoyoyo
| import java.util.Iterator;
| import java.util.List;
|
| import junit.framework.Test;
| import junit.framework.TestCase;
| import junit.framework.TestSuite;
|
| import org.jbpm.JbpmConfiguration;
| import org.jbpm.JbpmContext;
| import org.jbpm.graph.def.ProcessDefinition;
| import org.jbpm.graph.exe.ProcessInstance;
| import org.jbpm.taskmgmt.def.Swimlane;
| import org.jbpm.taskmgmt.exe.TaskInstance;
|
| public class JbpmTest extends TestCase {
|
| JbpmConfiguration jbpmCfg;
| JbpmContext jbpmContext;
|
| public JbpmDelegatorTest(String name) {
| super(name);
| }
|
| protected void setUp() {
| this.jbpmCfg = JbpmConfiguration.getInstance();
| this.jbpmContext = jbpmCfg.createJbpmContext();
| }
|
| protected void tearDown() {
| jbpmContext.close();
| }
|
| public void testDeployProcessXml() {
| String xmlResource = "returngoods.swimlane-pooled-actors/processdefinition.xml";
| ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource(xmlResource);
| jbpmContext.deployProcessDefinition(processDefinition);
| }
|
| public void testCreateStartTaskInstance() {
| ProcessDefinition processDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition("returngoods.swimlane-pooled-actors");
| // long processDefinitionId = processDefinition.getId();
|
| ProcessInstance processInstance = processDefinition.createProcessInstance();
| TaskInstance startTaskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
| startTaskInstance.end();
| jbpmContext.save(processInstance);
|
| List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo");
| assertTrue(pooledTaskInstances.size() > 0); //the 'Receive Item' task should be there according to the process definition
| TaskInstance taskInstanceOld = (TaskInstance) pooledTaskInstances.get(0);
| assertEquals("Receive Item", taskInstanceOld.getName());
| int oldVersion = taskInstanceOld.getTaskMgmtInstance().getTaskMgmtDefinition().getProcessDefinition().getVersion();
| System.out.println("oldVersion " + oldVersion);
|
| }
|
| public void testChangeProcessDefinition() {
| ProcessDefinition processDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition("returngoods.swimlane-pooled-actors");
|
| //removing yoyo from all swimlanes
| Swimlane swimlane = processDefinition.getTaskMgmtDefinition().getSwimlane("Shipping");
| swimlane.setActorIdExpression(null);
| swimlane.setPooledActorsExpression("grover");
|
| swimlane = processDefinition.getTaskMgmtDefinition().getSwimlane("Sales");
| swimlane.setActorIdExpression(null);
| swimlane.setPooledActorsExpression("ernie");
|
| swimlane = processDefinition.getTaskMgmtDefinition().getSwimlane("Accounting");
| swimlane.setActorIdExpression(null);
| swimlane.setPooledActorsExpression("bert");
|
| jbpmContext.deployProcessDefinition(processDefinition);
| }
|
| public void testCompleteTask() {
| List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo");
| assertTrue(pooledTaskInstances.size() > 0); //the 'Receive Item' task should be there according to the process definition
| TaskInstance taskInstanceNew = (TaskInstance) pooledTaskInstances.get(0);
| assertEquals("Receive Item", taskInstanceNew.getName());
| int newVersion = taskInstanceNew.getTaskMgmtInstance().getTaskMgmtDefinition().getProcessDefinition().getVersion();
|
| //The taskInstance is still there, but with new process version!
| System.out.println("newVersion "+ newVersion);
|
| taskInstanceNew.end();
| }
|
| public void testPooledTaskInstances() {
| List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo");
|
| // the suite failed here!
| assertTrue(pooledTaskInstances.size() > 0);
|
| for (Iterator iter = pooledTaskInstances.iterator(); iter.hasNext();) {
| TaskInstance taskInstance = (TaskInstance) iter.next();
| System.out.println("taskInstanceName " + taskInstance.getName());
| System.out.println("version " + taskInstance.getTaskMgmtInstance().getTaskMgmtDefinition().getProcessDefinition().getVersion());
| }
| }
|
| //clean up all pooledTaskInstances for yoyo to make the result clear
| public void testCleanUp() {
| List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo");
| for (Iterator iter = pooledTaskInstances.iterator(); iter.hasNext();) {
| TaskInstance taskInstance = (TaskInstance) iter.next();
| taskInstance.end();
| ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
| processInstance.end();
| jbpmContext.save(processInstance);
| }
| pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo");
| // assertNull(pooledTaskInstances);
| assertEquals(0, pooledTaskInstances.size());
| }
|
| public static Test suite() {
| TestSuite suite = new TestSuite("Test for jbpm");
| //$JUnit-BEGIN$
| suite.addTest(new JbpmDelegatorTest("testCleanUp"));
| suite.addTest(new JbpmDelegatorTest("testDeployProcessXml"));
|
| //start a process instance
| suite.addTest(new JbpmDelegatorTest("testCreateStartTaskInstance"));
|
| //do some changes in TaskMgmtDefinition
| suite.addTest(new JbpmDelegatorTest("testChangeProcessDefinition"));
|
| //complete the already assigned taskInstance
| suite.addTest(new JbpmDelegatorTest("testCompleteTask"));
|
| //test if the processInstance is still using the old process definition, but failed here
| suite.addTest(new JbpmDelegatorTest("testPooledTaskInstances"));
| //$JUnit-END$
| return suite;
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036908#4036908
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036908
19 years