KickJava   Java API By Example, From Geeks To Geeks.

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


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 WhileDbTest extends AbstractDbTestCase {
7   
8   public void testCondition() {
9     BpelDefinition processDefinition = new BpelDefinition();
10     While whileBlock = new While("parent");
11     Snippet condition = new Snippet();
12     condition.setUse(Snippet.Use.EXPRESSION);
13     condition.setText("false()");
14     whileBlock.setCondition(condition);
15     processDefinition.addNode(whileBlock);
16     
17     processDefinition = saveAndReload(processDefinition);
18
19     whileBlock = (While) processDefinition.getNode("parent");
20     assertEquals("false()", whileBlock.getCondition().getText());
21   }
22   
23   public void testConnections() {
24     BpelDefinition processDefinition = new BpelDefinition();
25     While whileBlock = new While("parent");
26     processDefinition.addNode(whileBlock);
27     Activity activity = new Empty("activity");
28     whileBlock.addNode(activity);
29     
30     processDefinition = saveAndReload(processDefinition);
31
32     whileBlock = (While) processDefinition.getNode("parent");
33     Activity start = whileBlock.getStart();
34     Activity end = whileBlock.getEnd();
35     Activity loopNode = whileBlock.getLoopNode();
36     activity = (Activity) whileBlock.getNode("activity");
37     
38     assertNotNull(loopNode);
39     assertEquals(whileBlock, loopNode.getCompositeActivity());
40     
41     assertEquals( start.getDefaultLeavingTransition().getTo(), loopNode );
42     assertEquals( end.getDefaultArrivingTransition().getFrom(), loopNode );
43     
44     assertTrue( loopNode.getArrivingTransitions().contains(activity.getDefaultLeavingTransition()) );
45     assertTrue( loopNode.getLeavingTransitions().contains(activity.getDefaultArrivingTransition()) );
46     assertTrue( loopNode.getArrivingTransitions().contains(activity.getDefaultLeavingTransition()) );
47   }
48 }
Popular Tags