1 package org.jbpm.graph.def; 2 3 import junit.framework.TestCase; 4 5 public class ParentTest extends TestCase { 6 7 ProcessDefinition processDefinition = null; 8 9 public void testProcessDefinitionParent() { 10 assertNull(new ProcessDefinition().getParent()); 11 } 12 13 public void testNodeInProcessParents() { 14 processDefinition = ProcessDefinition.parseXmlString( 15 "<process-definition>" + 16 " <start-state name='start'>" + 17 " <transition to='state'/>" + 18 " </start-state>" + 19 " <state name='state'>" + 20 " <transition to='end'/>" + 21 " </state>" + 22 " <end-state name='end'/>" + 23 "</process-definition>" 24 ); 25 26 assertSame(processDefinition, processDefinition.getStartState().getParent()); 27 assertSame(processDefinition, processDefinition.getNode("state").getParent()); 28 assertSame(processDefinition, processDefinition.getNode("end").getParent()); 29 } 30 31 public void testTransitionInProcessParents() { 32 processDefinition = ProcessDefinition.parseXmlString( 33 "<process-definition>" + 34 " <start-state name='start'>" + 35 " <transition to='state'/>" + 36 " </start-state>" + 37 " <state name='state'>" + 38 " <transition to='end'/>" + 39 " </state>" + 40 " <end-state name='end'/>" + 41 "</process-definition>" 42 ); 43 assertSame(processDefinition, processDefinition.getStartState().getDefaultLeavingTransition().getParent()); 44 assertSame(processDefinition, processDefinition.getNode("state").getDefaultLeavingTransition().getParent()); 45 } 46 47 public void testNodeInSuperProcessParent() { 48 processDefinition = ProcessDefinition.parseXmlString( 49 "<process-definition>" + 50 " <start-state name='start'>" + 51 " <transition to='superstate/state'/>" + 52 " </start-state>" + 53 " <super-state name='superstate'>" + 54 " <state name='state'>" + 55 " <transition to='../end'/>" + 56 " </state>" + 57 " </super-state>" + 58 " <end-state name='end'/>" + 59 "</process-definition>" 60 ); 61 62 SuperState superState = (SuperState) processDefinition.getNode("superstate"); 63 64 assertSame(processDefinition, processDefinition.getStartState().getParent()); 65 assertSame(processDefinition, superState.getParent()); 66 assertSame(processDefinition, processDefinition.getNode("end").getParent()); 67 assertSame(superState, processDefinition.findNode("superstate/state").getParent()); 68 } 69 70 public void testTransitionInSuperProcessParent() { 71 processDefinition = ProcessDefinition.parseXmlString( 72 "<process-definition>" + 73 " <start-state name='start'>" + 74 " <transition to='superstate/state'/>" + 75 " </start-state>" + 76 " <super-state name='superstate'>" + 77 " <state name='state'>" + 78 " <transition to='../end'/>" + 79 " <transition name='loop' to='state'/>" + 80 " <transition name='tostate2' to='state2'/>" + 81 " </state>" + 82 " <state name='state2' />" + 83 " </super-state>" + 84 " <end-state name='end'/>" + 85 "</process-definition>" 86 ); 87 88 SuperState superState = (SuperState) processDefinition.getNode("superstate"); 89 90 assertSame(processDefinition, processDefinition.getStartState().getDefaultLeavingTransition().getParent()); 91 assertSame(processDefinition, processDefinition.findNode("superstate/state").getDefaultLeavingTransition().getParent()); 92 assertSame(superState, processDefinition.findNode("superstate/state").getLeavingTransition("loop").getParent()); 93 assertSame(superState, processDefinition.findNode("superstate/state").getLeavingTransition("tostate2").getParent()); 94 } 95 } 96 | Popular Tags |