1 package org.jbpm.bpel.def; 2 3 import org.jbpm.bpel.db.AbstractDbTestCase; 4 import org.jbpm.bpel.service.def.Receiver; 5 import org.jbpm.bpel.timer.def.Alarm; 6 7 public class PickDbTest extends AbstractDbTestCase { 8 9 public void testEvents() { 10 BpelDefinition processDefinition = new BpelDefinition(); 11 Pick pick = new Pick("parent"); 12 processDefinition.addNode(pick); 13 Activity receiverActivity = new Empty("receiver"); 14 Activity alarmActivity = new Empty("alarm"); 15 pick.addNode(receiverActivity); 16 Receiver receiver = new Receiver(pick); 17 pick.setOnMessage(receiverActivity, receiver); 18 pick.addNode(alarmActivity); 19 Alarm alarm = new Alarm(pick); 20 alarm.setAlarmKind(Alarm.AlarmKind.DEADLINE); 21 pick.setOnAlarm(alarmActivity, alarm); 22 23 processDefinition = saveAndReload(processDefinition); 24 25 pick = (Pick) processDefinition.getNode("parent"); 26 receiverActivity = (Activity) pick.getNode("receiver"); 27 alarmActivity = (Activity) pick.getNode("alarm"); 28 29 assertEquals(1, pick.getOnAlarms().size()); 30 assertEquals(1, pick.getOnMessages().size()); 31 32 receiver = (Receiver) pick.getOnMessages().get(0); 33 alarm = (Alarm) pick.getOnAlarms().get(0); 34 35 assertEquals(receiverActivity, pick.getOnMessage(receiver)); 36 assertEquals(alarmActivity, pick.getOnAlarm(alarm)); 37 38 } 41 42 public void testConnections() { 43 BpelDefinition processDefinition = new BpelDefinition(); 44 Pick pick = new Pick("parent"); 45 processDefinition.addNode(pick); 46 Activity activity = new Empty("activity"); 47 pick.addNode(activity); 48 pick.setOnMessage(activity, new Receiver(pick)); 49 50 processDefinition = saveAndReload(processDefinition); 51 52 pick = (Pick) processDefinition.getNode("parent"); 53 Activity start = pick.getStart(); 54 Activity end = pick.getEnd(); 55 activity = (Activity) pick.getNode("activity"); 56 57 assertTrue(start.getLeavingTransitions().contains(activity.getDefaultArrivingTransition())); 58 assertTrue(end.getArrivingTransitions().contains(activity.getDefaultLeavingTransition())); 59 } 60 } | Popular Tags |