KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > jpdl > exe > DecisionConditionsTest


1 package org.jbpm.jpdl.exe;
2
3 import junit.framework.TestCase;
4
5 import org.jbpm.graph.def.ProcessDefinition;
6 import org.jbpm.graph.exe.ProcessInstance;
7
8 public class DecisionConditionsTest extends TestCase {
9   
10   ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
11     "<process-definition>" +
12     " <start-state>" +
13     " <transition to='d' />" +
14     " </start-state>" +
15     " <decision name='d'>" +
16     " <transition name='imporant lead' to='harras them'>" +
17     " <condition>budget > 1000</condition>" +
18     " </transition>" +
19     " <transition name='lead' to='put it in the lead db'>" +
20     " <condition>budget > 100</condition>" +
21     " </transition>" +
22     " <transition name='beggars' to='forget about it'/>" +
23     " </decision>" +
24     " <state name='harras them' />" +
25     " <state name='put it in the lead db' />" +
26     " <state name='forget about it' />" +
27     "</process-definition>" );
28   
29   public void testBudgetHignerThenThousand() {
30     ProcessInstance processInstance = new ProcessInstance(processDefinition);
31     processInstance.getContextInstance().setVariable("budget", new Integer JavaDoc(3500));
32     processInstance.signal();
33     
34     assertEquals(processDefinition.getNode("harras them"), processInstance.getRootToken().getNode());
35   }
36
37   public void testBudgetBetweenHundredAndThousand() {
38     ProcessInstance processInstance = new ProcessInstance(processDefinition);
39     processInstance.getContextInstance().setVariable("budget", new Integer JavaDoc(350));
40     processInstance.signal();
41     
42     assertEquals(processDefinition.getNode("put it in the lead db"), processInstance.getRootToken().getNode());
43   }
44
45   public void testSmallBudget() {
46     ProcessInstance processInstance = new ProcessInstance(processDefinition);
47     processInstance.getContextInstance().setVariable("budget", new Integer JavaDoc(35));
48     processInstance.signal();
49     
50     assertEquals(processDefinition.getNode("forget about it"), processInstance.getRootToken().getNode());
51   }
52
53 }
54
Popular Tags