KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > graph > exe > ProcessInstanceDbTest


1 package org.jbpm.graph.exe;
2
3 import org.jbpm.context.exe.ContextInstance;
4 import org.jbpm.db.AbstractDbTestCase;
5 import org.jbpm.graph.def.ProcessDefinition;
6 import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
7
8 public class ProcessInstanceDbTest extends AbstractDbTestCase {
9
10   public void testProcessInstanceProcessDefinition() {
11     ProcessDefinition processDefinition = new ProcessDefinition("definition");
12     graphSession.saveProcessDefinition(processDefinition);
13     ProcessInstance processInstance = new ProcessInstance(processDefinition);
14
15     processInstance = saveAndReload(processInstance);
16
17     assertNotNull(processInstance);
18     processDefinition = processInstance.getProcessDefinition();
19     assertEquals("definition", processDefinition.getName());
20   }
21
22   public void testProcessInstanceDates() {
23     ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
24       "<process-definition>" +
25       " <start-state>" +
26       " <transition to='end' />" +
27       " </start-state>" +
28       " <end-state name='end'/>" +
29       "</process-definition>" );
30     graphSession.saveProcessDefinition(processDefinition);
31     ProcessInstance processInstance = new ProcessInstance(processDefinition);
32     processInstance.signal();
33
34     processInstance = saveAndReload(processInstance);
35     
36     assertNotNull(processInstance.getStart());
37     assertNotNull(processInstance.getEnd());
38   }
39
40   public void testProcessInstanceRootToken() {
41     ProcessDefinition processDefinition = new ProcessDefinition();
42     graphSession.saveProcessDefinition(processDefinition);
43     ProcessInstance processInstance = new ProcessInstance(processDefinition);
44
45     processInstance = saveAndReload(processInstance);
46     
47     assertNotNull(processInstance.getRootToken());
48   }
49
50   public void testProcessInstanceSuperProcessToken() {
51     ProcessDefinition superProcessDefinition = new ProcessDefinition("super");
52     ProcessInstance superProcessInstance = new ProcessInstance(superProcessDefinition);
53     Token superProcessToken = superProcessInstance.getRootToken();
54     graphSession.saveProcessDefinition(superProcessDefinition);
55     graphSession.saveProcessInstance(superProcessInstance);
56     
57     ProcessInstance processInstance = new ProcessInstance();
58     processInstance.setSuperProcessToken(superProcessToken);
59
60     processInstance = saveAndReload(processInstance);
61
62     superProcessToken = processInstance.getSuperProcessToken();
63     assertNotNull(superProcessToken);
64     superProcessInstance = superProcessToken.getProcessInstance();
65     assertNotNull(superProcessInstance);
66     superProcessDefinition = superProcessInstance.getProcessDefinition();
67     assertEquals("super", superProcessDefinition.getName());
68   }
69   
70   public void testProcessInstanceModuleInstances() {
71     ProcessInstance processInstance = new ProcessInstance();
72     processInstance.addInstance(new ContextInstance());
73     processInstance.addInstance(new TaskMgmtInstance());
74    
75     processInstance = saveAndReload(processInstance);
76
77     assertNotNull(processInstance.getInstances());
78     assertEquals(2, processInstance.getInstances().size());
79     assertNotNull(processInstance.getContextInstance());
80     assertNotNull(processInstance.getTaskMgmtInstance());
81   }
82   
83   public void testProcessInstanceRuntimeActions() {
84     ProcessInstance processInstance = new ProcessInstance();
85     processInstance.addRuntimeAction(new RuntimeAction());
86     processInstance.addRuntimeAction(new RuntimeAction());
87     processInstance.addRuntimeAction(new RuntimeAction());
88     processInstance.addRuntimeAction(new RuntimeAction());
89    
90     processInstance = saveAndReload(processInstance);
91
92     assertNotNull(processInstance.getRuntimeActions());
93     assertEquals(4, processInstance.getRuntimeActions().size());
94   }
95 }
96
Popular Tags