1 package org.jbpm.graph.def; 2 3 import java.util.Iterator ; 4 5 import org.jbpm.db.AbstractDbTestCase; 6 7 public class EventDbTest extends AbstractDbTestCase { 8 9 public void testEventEventType() { 10 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 11 "<process-definition>" + 12 " <event type='process-start' />" + 13 "</process-definition>"); 14 15 processDefinition = saveAndReload(processDefinition); 16 17 assertEquals("process-start", processDefinition.getEvent("process-start").getEventType()); 18 } 19 20 public void testEventGraphElementProcessDefinition() { 21 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 22 "<process-definition>" + 23 " <event type='process-start' />" + 24 "</process-definition>"); 25 26 assertSame(processDefinition, processDefinition.getEvent("process-start").getGraphElement()); 27 28 processDefinition = saveAndReload(processDefinition); 29 30 assertSame(processDefinition, processDefinition.getEvent("process-start").getGraphElement()); 31 } 32 33 public void testEventGraphElementNode() { 34 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 35 "<process-definition>" + 36 " <node name='n'>" + 37 " <event type='node-enter'/>" + 38 " </node>" + 39 "</process-definition>"); 40 41 processDefinition = saveAndReload(processDefinition); 42 43 assertSame(processDefinition.getNode("n"), processDefinition.getNode("n").getEvent("node-enter").getGraphElement()); 44 } 45 46 public void testEventGraphElementTransition() { 47 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 48 "<process-definition>" + 49 " <node name='n'>" + 50 " <transition name='t' to='n'>" + 51 " <action class='unimportant'/>" + 52 " </transition>" + 53 " </node>" + 54 "</process-definition>"); 55 56 processDefinition = saveAndReload(processDefinition); 57 58 Transition t = processDefinition.getNode("n").getLeavingTransition("t"); 59 assertSame(t, t.getEvent("transition").getGraphElement()); 60 } 61 62 public void testEventActions() { 63 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 64 "<process-definition>" + 65 " <event type='process-start'>" + 66 " <action class='a'/>" + 67 " <action class='b'/>" + 68 " <action class='c'/>" + 69 " <action class='d'/>" + 70 " </event>" + 71 "</process-definition>"); 72 73 processDefinition = saveAndReload(processDefinition); 74 75 Iterator iter = processDefinition.getEvent("process-start").getActions().iterator(); 76 assertEquals("a", ((Action)iter.next()).getActionDelegation().getClassName()); 77 assertEquals("b", ((Action)iter.next()).getActionDelegation().getClassName()); 78 assertEquals("c", ((Action)iter.next()).getActionDelegation().getClassName()); 79 assertEquals("d", ((Action)iter.next()).getActionDelegation().getClassName()); 80 } 81 82 } 83 | Popular Tags |