KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > taskmgmt > def > TaskMgmtDefinitionDbTest


1 package org.jbpm.taskmgmt.def;
2
3 import org.jbpm.db.*;
4 import org.jbpm.graph.def.*;
5
6 public class TaskMgmtDefinitionDbTest extends AbstractDbTestCase {
7   
8   ProcessDefinition processDefinition = null;
9   TaskMgmtDefinition taskMgmtDefinition = null;
10   Swimlane buyer = null;
11   Swimlane seller = null;
12   Task laundry = null;
13   Task dishes = null;
14   
15   public void setUp() {
16     super.setUp();
17     
18     processDefinition = new ProcessDefinition();
19     taskMgmtDefinition = new TaskMgmtDefinition();
20     processDefinition.addDefinition(taskMgmtDefinition);
21     buyer = new Swimlane("buyer");
22     seller = new Swimlane("seller");
23     laundry = new Task("laundry");
24     dishes = new Task("dishes");
25   }
26   
27   public void testTaskMgmtDefinitionAddSwimlanes() {
28     taskMgmtDefinition.addSwimlane(buyer);
29     taskMgmtDefinition.addSwimlane(seller);
30     
31     processDefinition = saveAndReload(processDefinition);
32     taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
33     
34     assertEquals(2, taskMgmtDefinition.getSwimlanes().size());
35     assertEquals("buyer", taskMgmtDefinition.getSwimlane("buyer").getName());
36     assertEquals("seller", taskMgmtDefinition.getSwimlane("seller").getName());
37   }
38
39   public void testTaskMgmtDefinitionAddSwimlaneInverseReference() {
40     taskMgmtDefinition.addSwimlane(buyer);
41     taskMgmtDefinition.addSwimlane(seller);
42     
43     processDefinition = saveAndReload(processDefinition);
44     taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
45     
46     assertSame(taskMgmtDefinition, taskMgmtDefinition.getSwimlane("buyer").getTaskMgmtDefinition());
47     assertSame(taskMgmtDefinition, taskMgmtDefinition.getSwimlane("seller").getTaskMgmtDefinition());
48   }
49
50   public void testTaskMgmtDefinitionAddTasks() {
51     taskMgmtDefinition.addTask(laundry);
52     taskMgmtDefinition.addTask(dishes);
53     
54     processDefinition = saveAndReload(processDefinition);
55     taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
56     
57     assertEquals(2, taskMgmtDefinition.getTasks().size());
58     assertEquals("laundry", taskMgmtDefinition.getTask("laundry").getName());
59     assertEquals("dishes", taskMgmtDefinition.getTask("dishes").getName());
60   }
61   
62   public void testTaskMgmtDefinitionAddTasksInverseReference() {
63     taskMgmtDefinition.addTask(laundry);
64     taskMgmtDefinition.addTask(dishes);
65     
66     processDefinition = saveAndReload(processDefinition);
67     taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
68     
69     assertSame(taskMgmtDefinition, taskMgmtDefinition.getTask("laundry").getTaskMgmtDefinition());
70     assertSame(taskMgmtDefinition, taskMgmtDefinition.getTask("dishes").getTaskMgmtDefinition());
71   }
72 }
73
Popular Tags