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 ActivityDbTest extends AbstractDbTestCase { 7 8 public void testBpelDefinition() { 9 BpelDefinition processDefinition = new BpelDefinition("p"); 10 Activity activity = new Empty("activity"); 11 processDefinition.getScope().addNode(activity); 12 13 processDefinition = saveAndReload(processDefinition); 14 15 assertNotNull(processDefinition); 16 activity = (Activity) processDefinition.getScope().getNode("activity"); 17 assertEquals( processDefinition, activity.getProcessDefinition() ); 18 } 19 20 public void testCompositeActivity() { 21 BpelDefinition processDefinition = new BpelDefinition(); 22 CompositeActivity parent = new Sequence("parent"); 23 processDefinition.addNode(parent); 24 25 Activity activity = new Empty("activity"); 26 parent.addNode(activity); 27 28 processDefinition = saveAndReload(processDefinition); 29 30 parent = (CompositeActivity) processDefinition.getNode("parent"); 31 activity = (Activity) parent.getNode("activity"); 32 assertNotNull(activity); 33 assertNotNull(parent); 34 assertSame(activity, parent.getNode("activity")); 35 assertSame(activity.getCompositeActivity(), parent); 36 } 37 38 public void testJoinCondition() { 39 BpelDefinition processDefinition = new BpelDefinition(); 40 Activity activity = new Empty("activity"); 41 Snippet joinCondition = new Snippet(); 42 joinCondition.setUse(Snippet.Use.JOIN_CONDITION); 43 activity.setJoinCondition(joinCondition); 44 processDefinition.addNode(activity); 45 46 processDefinition = saveAndReload(processDefinition); 47 48 assertNotNull( ((Activity)processDefinition.getNode("activity")).getJoinCondition() ); 49 } 50 51 public void testSupressJoinFailure() { 52 BpelDefinition processDefinition = new BpelDefinition(); 53 Activity activity = new Empty("activity"); 54 activity.setSuppressJoinFailure(Boolean.TRUE); 55 processDefinition.addNode(activity); 56 57 processDefinition = saveAndReload(processDefinition); 58 59 assertEquals(Boolean.TRUE, ((Activity)processDefinition.getNode("activity")).getSuppressJoinFailure()); 60 } 61 62 public void testSourcesAndTargets() { 63 BpelDefinition processDefinition = new BpelDefinition(); 64 Activity a = new Empty("a"); 65 Activity b = new Empty("b"); 66 processDefinition.addNode(a); 67 processDefinition.addNode(b); 68 69 Link link = new Link("one"); 70 a.addSource(link); 71 b.addTarget(link); 72 73 link = new Link("two"); 74 a.addSource(link); 75 b.addTarget(link); 76 77 link = new Link("three"); 78 a.addSource(link); 79 b.addTarget(link); 80 81 processDefinition = saveAndReload(processDefinition); 82 83 a = (Activity) processDefinition.getNode("a"); 84 b = (Activity) processDefinition.getNode("b"); 85 86 assertEquals(3, a.getSources().size()); 87 assertEquals(0, a.getTargets().size()); 88 89 assertEquals(0, b.getSources().size()); 90 assertEquals(3, b.getTargets().size()); 91 92 assertTrue(a.getSources().containsAll(b.getTargets())); 93 } 94 } 95 | Popular Tags |