1 package org.jbpm.bpel.def; 2 3 import java.util.Collection ; 4 5 import junit.framework.TestCase; 6 7 11 public class FlowDefTest extends TestCase { 12 Flow flow; 13 Activity first; 14 Activity second; 15 16 public void setUp() { 17 flow = new Flow(); 18 first = new Empty("first"); 19 second = new Empty("second"); 20 } 21 22 public void testAddNode() { 23 flow.addNode(first); 24 assertConnected(first); 25 flow.addNode(second); 26 assertConnected(second); 27 } 28 29 public void testRemoveNode() { 30 flow.addNode(first); 32 flow.addNode(second); 33 34 flow.removeNode(first); 35 assertDisconnected(first); 36 flow.removeNode(second); 37 assertDisconnected(second); 38 39 assertEquals(0, flow.getStart().getLeavingTransitions().size()); 40 assertEquals(0, flow.getEnd().getArrivingTransitions().size()); 41 } 42 43 private void assertConnected(Activity activity) { 44 Collection transitions = flow.getStart().getLeavingTransitions(); 45 assertTrue( transitions.contains( activity.getDefaultArrivingTransition() ) ); 46 47 transitions = flow.getEnd().getArrivingTransitions(); 48 assertTrue( transitions.contains(activity.getDefaultLeavingTransition()) ); 49 } 50 51 private void assertDisconnected(Activity activity) { 52 assertEquals(0, activity.getArrivingTransitions().size()); 54 assertEquals(0, activity.getLeavingTransitions().size()); 55 } 56 57 } 58 | Popular Tags |