KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > graph > def > MultipleProcessDefinitionEventsDbTest


1 package org.jbpm.graph.def;
2
3 import java.util.Map JavaDoc;
4
5 import org.jbpm.db.AbstractDbTestCase;
6 import org.jbpm.graph.node.State;
7 import org.jbpm.jpdl.par.ProcessArchiveDeployer;
8
9 public class MultipleProcessDefinitionEventsDbTest extends AbstractDbTestCase {
10
11   public void testEventPersistence() {
12
13     // Add a start state so that state '1' gets assigned id = 2
14
ProcessDefinition processDefinitionOne = ProcessDefinition.parseXmlString(
15       "<process-definition name='one'>" +
16       " <start-state name='start'>" +
17       " <transition name='start transition to 1' to='1' />" +
18       " </start-state>" +
19       " <state name='1'>" +
20       " <event type='node-enter'>" +
21       " <action class='foo' />" +
22       " </event>" +
23       " </state>" +
24       "</process-definition>"
25     );
26
27     ProcessArchiveDeployer.deployProcessDefinition(processDefinitionOne);
28
29     newTransaction();
30
31     ProcessDefinition processDefinitionTwo = ProcessDefinition.parseXmlString(
32       "<process-definition name='two'>" +
33       " <state name='1'>" +
34       " <event type='node-enter'>" +
35       " <action class='bar' />" +
36       " </event>" +
37       " </state>" +
38       "</process-definition>"
39     );
40
41     ProcessArchiveDeployer.deployProcessDefinition(processDefinitionTwo);
42
43     newTransaction();
44
45     processDefinitionOne = jbpmSession.getGraphSession().loadProcessDefinition(processDefinitionOne.getId());
46     processDefinitionTwo = jbpmSession.getGraphSession().loadProcessDefinition(processDefinitionTwo.getId());
47
48     State stateOne = (State) processDefinitionOne.getNode("1");
49     State stateTwo = (State) processDefinitionTwo.getNode("1");
50     assertTrue(stateOne.getEvent("node-enter") != stateTwo.getEvent("node-enter"));
51
52     Map JavaDoc processEvents = processDefinitionTwo.getEvents();
53     System.out.println(processDefinitionTwo.getEvents());
54     assertEquals("Process Definition should not have any events. events = " + processEvents, 0, processEvents.size());
55   }
56 }
57
Popular Tags