KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jbpm.graph.def;
2
3 import junit.framework.*;
4
5 public class DefaultTransitionTest extends TestCase {
6   
7   private Node n = new Node();
8   private Node n2 = new Node();
9   private Node n3 = new Node();
10   private Transition t = new Transition();
11   private Transition t1 = new Transition("one");
12   private Transition t2 = new Transition("two");
13   private Transition t3 = new Transition("three");
14
15   public void testOneTransition() {
16     n.addLeavingTransition(t);
17     assertSame(t, n.getDefaultLeavingTransition());
18   }
19
20   public void testUnnamedAndNamedTransition() {
21     n.addLeavingTransition(t);
22     n.addLeavingTransition(t1);
23     assertSame(t, n.getDefaultLeavingTransition());
24   }
25
26   public void testNamedAndUnnamedTransition() {
27     n.addLeavingTransition(t1);
28     n.addLeavingTransition(t);
29     assertSame(t1, n.getDefaultLeavingTransition());
30   }
31
32   public void test3NamedTransitions() {
33     n.addLeavingTransition(t1);
34     n.addLeavingTransition(t2);
35     n.addLeavingTransition(t3);
36     assertSame(t1, n.getDefaultLeavingTransition());
37   }
38
39   public void testAddRemoveAddScenario() {
40     n.addLeavingTransition(t1);
41     n.addLeavingTransition(t2);
42     n.addLeavingTransition(t3);
43     assertSame(t1, n.getDefaultLeavingTransition());
44     n.removeLeavingTransition(t1);
45     assertSame(t2, n.getDefaultLeavingTransition());
46     n.removeLeavingTransition(t2);
47     assertSame(t3, n.getDefaultLeavingTransition());
48     n.removeLeavingTransition(t3);
49     assertNull(n.getDefaultLeavingTransition());
50     n.addLeavingTransition(t2);
51     assertSame(t2, n.getDefaultLeavingTransition());
52   }
53
54   public void testDestinationOfDefaultTransition() {
55     n.addLeavingTransition(t);
56     n.removeLeavingTransition(t);
57     n2.addLeavingTransition(t);
58     n3.addLeavingTransition(t2);
59     n3.removeLeavingTransition(t2);
60     n2.addLeavingTransition(t2);
61     
62     assertEquals( n2, n2.getDefaultLeavingTransition().getFrom() );
63   }
64 }
65
Popular Tags