1 package org.jbpm.jpdl.patterns; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 6 import junit.framework.TestCase; 7 8 import org.jbpm.graph.def.ProcessDefinition; 9 import org.jbpm.graph.exe.ProcessInstance; 10 import org.jbpm.graph.exe.Token; 11 import org.jbpm.taskmgmt.exe.TaskInstance; 12 import org.jbpm.taskmgmt.exe.TaskMgmtInstance; 13 14 17 public class Wfp14MiWithAPrioriDesigntimeKnowledgeTest extends TestCase { 18 19 public void testSituation1() { 20 ProcessDefinition pd = ProcessDefinition.parseXmlString( 21 "<process-definition name='the life of a baby ?'>" + 22 " <start-state name='a'>" + 23 " <transition to='b' />" + 24 " </start-state>" + 25 " <state name='b'>" + 26 " <transition to='t' />" + 27 " </state>" + 28 " <task-node name='t'>" + 29 " <task name='eat' />" + 30 " <task name='drink' />" + 31 " <task name='sleep' />" + 32 " <transition to='c' />" + 33 " </task-node>" + 34 " <state name='c' />" + 35 "</process-definition>" 36 ); 37 38 ProcessInstance pi = new ProcessInstance( pd ); 39 TaskMgmtInstance taskMgmtInstance = (TaskMgmtInstance) pi.getInstance(TaskMgmtInstance.class); 40 41 pi.signal(); 42 Token token = pi.getRootToken(); 43 44 assertSame( pd.getNode("b"), token.getNode() ); 46 47 assertEquals(0, taskMgmtInstance.getUnfinishedTasks(token).size() ); 49 50 pi.signal(); 54 55 List tasks = new ArrayList ( taskMgmtInstance.getUnfinishedTasks(token) ); 57 assertEquals(3, tasks.size()); 58 assertSame( pd.getNode("t"), token.getNode() ); 60 61 ((TaskInstance)tasks.get(0)).end(); 64 65 assertEquals(2, taskMgmtInstance.getUnfinishedTasks(token).size() ); 67 assertSame( pd.getNode("t"), token.getNode() ); 69 70 ((TaskInstance)tasks.get(1)).end(); 72 73 assertEquals(1, taskMgmtInstance.getUnfinishedTasks(token).size() ); 75 assertSame( pd.getNode("t"), token.getNode() ); 77 78 ((TaskInstance)tasks.get(2)).end(); 80 81 assertEquals(0, taskMgmtInstance.getUnfinishedTasks(token).size() ); 83 assertEquals( pd.getNode("c"), token.getNode() ); 85 } 86 } 87 | Popular Tags |