1 package org.jbpm.graph.def; 2 3 import java.util.HashSet ; 4 import java.util.Set ; 5 6 import junit.framework.TestCase; 7 8 import org.jbpm.graph.node.Decision; 9 import org.jbpm.graph.node.EndState; 10 import org.jbpm.graph.node.Fork; 11 import org.jbpm.graph.node.InterleaveEnd; 12 import org.jbpm.graph.node.InterleaveStart; 13 import org.jbpm.graph.node.Join; 14 import org.jbpm.graph.node.Merge; 15 import org.jbpm.graph.node.MilestoneNode; 16 import org.jbpm.graph.node.ProcessState; 17 import org.jbpm.graph.node.StartState; 18 import org.jbpm.graph.node.State; 19 import org.jbpm.graph.node.TaskNode; 20 import org.jbpm.taskmgmt.def.Task; 21 22 34 public class SupportedEventsTest extends TestCase { 35 36 public void testNodeEvents() { 37 assertSupportedEvents(new Node(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 38 } 39 40 public void testDecisionEvents() { 41 assertSupportedEvents(new Decision(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 42 } 43 44 public void testEndStateEvents() { 45 assertSupportedEvents(new EndState(), new String [] { "node-enter" }); 46 } 47 48 public void testForkEvents() { 49 assertSupportedEvents(new Fork(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 50 } 51 52 public void testInterleaveEndEvents() { 53 assertSupportedEvents(new InterleaveEnd(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 54 } 55 56 public void testInterleaveStartEvents() { 57 assertSupportedEvents(new InterleaveStart(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 58 } 59 60 public void testJoinEvents() { 61 assertSupportedEvents(new Join(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 62 } 63 64 public void testMergeEvents() { 65 assertSupportedEvents(new Merge(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 66 } 67 68 public void testMilestoneNodeEvents() { 69 assertSupportedEvents(new MilestoneNode(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 70 } 71 72 public void testProcessStateEvents() { 73 assertSupportedEvents(new ProcessState(), new String [] { "node-leave", "node-enter", "after-signal", "before-signal", "subprocess-created", 74 "subprocess-end" }); 75 } 76 77 public void testStartStateEvents() { 78 assertSupportedEvents(new StartState(), new String [] { "node-leave", "after-signal" }); 79 } 80 81 public void testStateEvents() { 82 assertSupportedEvents(new State(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 83 } 84 85 public void testSuperStateEvents() { 86 assertSupportedEvents(new SuperState(), new String [] { "transition", "before-signal", "after-signal", "node-enter", "node-leave", "superstate-enter", 87 "superstate-leave", "subprocess-created", "subprocess-end", "task-create", "task-assign", "task-start", "task-end", "timer" }); 88 } 89 90 public void testTaskNodeEvents() { 91 assertSupportedEvents(new TaskNode(), new String [] { "node-enter", "node-leave", "before-signal", "after-signal" }); 92 } 93 94 public void testTaskEvents() { 95 assertSupportedEvents(new Task(), new String [] { "task-create", "task-assign", "task-start", "task-end" }); 96 } 97 98 public void testProcessDefinitionEvents() { 99 assertSupportedEvents(new ProcessDefinition(), new String [] { "transition", "before-signal", "after-signal", "process-start", "process-end", "node-enter", 100 "node-leave", "superstate-enter", "superstate-leave", "subprocess-created", "subprocess-end", "task-create", "task-assign", "task-start", "task-end", 101 "timer" }); 102 } 103 104 public void testTransitionEvents() { 105 assertSupportedEvents(new Transition(), new String [] { "transition" }); 106 } 107 108 private void assertSupportedEvents(GraphElement graphElement, String [] expectedEventTypes) { 109 String [] supportedEventTypes = graphElement.getSupportedEventTypes(); 110 111 Set expectedSet = getHashSet(expectedEventTypes); 112 Set supportedSet = getHashSet(supportedEventTypes); 113 114 assertEquals(expectedSet, supportedSet); 115 } 116 117 private HashSet getHashSet(String [] strings) { 118 HashSet set = new HashSet (); 119 for (int i = 0; i < strings.length; i++) { 120 set.add(strings[i]); 121 } 122 return set; 123 } 124 } 125 | Popular Tags |