KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > def > SwitchDbTest


1 package org.jbpm.bpel.def;
2
3 import org.jbpm.bpel.data.def.Snippet;
4 import org.jbpm.bpel.db.AbstractDbTestCase;
5
6 public class SwitchDbTest extends AbstractDbTestCase {
7   
8   public void testCase() {
9     BpelDefinition processDefinition = new BpelDefinition();
10     Switch switchBlock = new Switch("parent");
11     processDefinition.addNode(switchBlock);
12     Activity activity = new Empty("activity");
13     switchBlock.addNode(activity);
14     Snippet condition = new Snippet();
15     condition.setUse(Snippet.Use.EXPRESSION);
16     switchBlock.setCondition(activity, condition);
17     
18     processDefinition = saveAndReload(processDefinition);
19
20     switchBlock = (Switch) processDefinition.getNode("parent");
21     activity = (Activity) switchBlock.getNode("activity");
22     assertNotNull(switchBlock.getCondition(activity));
23   }
24   
25   public void testOtherwise() {
26     BpelDefinition processDefinition = new BpelDefinition();
27     Switch switchBlock = new Switch("parent");
28     processDefinition.addNode(switchBlock);
29     Activity otherwise = new Empty("otherwise");
30     switchBlock.setOtherwise(otherwise);
31     
32     processDefinition = saveAndReload(processDefinition);
33
34     switchBlock = (Switch) processDefinition.getNode("parent");
35     otherwise = switchBlock.getOtherwise();
36     assertNotNull( otherwise );
37   }
38   
39   public void testConnections() {
40     BpelDefinition processDefinition = new BpelDefinition();
41     Switch switchBlock = new Switch("parent");
42     processDefinition.addNode(switchBlock);
43     Activity activity = new Empty("activity");
44     switchBlock.addNode(activity);
45     Snippet expression = new Snippet();
46     expression.setUse(Snippet.Use.EXPRESSION);
47     switchBlock.setCondition(activity, expression);
48     
49     processDefinition = saveAndReload(processDefinition);
50
51     switchBlock = (Switch) processDefinition.getNode("parent");
52     Activity start = switchBlock.getStart();
53     Activity end = switchBlock.getEnd();
54     activity = (Activity) switchBlock.getNode("activity");
55     assertTrue(start.getLeavingTransitions().contains(activity.getDefaultArrivingTransition()));
56     assertTrue(end.getArrivingTransitions().contains(activity.getDefaultLeavingTransition()));
57   }
58 }
Popular Tags