1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  package org.kuali.rice.kew.engine.node;
20  
21  import static org.junit.Assert.assertEquals;
22  import static org.junit.Assert.assertFalse;
23  import static org.junit.Assert.assertNotNull;
24  import static org.junit.Assert.assertTrue;
25  
26  import java.util.List;
27  
28  import org.junit.Test;
29  import org.kuali.rice.kew.test.KEWTestCase;
30  
31  
32  
33  
34  
35  
36  public class BranchTest extends KEWTestCase {
37  
38      private Branch branch;
39      
40      public BranchTest() {
41          super();
42      }
43      
44      @Test public void testBranchStateIsLazyLoadable() {
45          branch = new Branch();
46          List<BranchState> branchStates = branch.getBranchState();
47          assertNotNull("new branchStates should not be null", branchStates);
48          assertEquals("new branchStates should be empty", 0, branchStates.size());
49          
50          
51          
52          boolean errorThrown = false;
53          try {
54              branchStates.get(0);
55          }
56          catch (IndexOutOfBoundsException e) {
57              errorThrown = true;
58          }
59          assertTrue("An IndexOutOfBoundsException should have been thrown", errorThrown);
60          
61          
62          errorThrown = false;
63          try {
64              branch.getDocBranchState(0);
65          }
66          catch (Exception e) {
67              errorThrown = true;
68          }
69          assertFalse("No exception should have been thrown", errorThrown);
70          assertEquals("There should now be one element in the list (empty)", 1, branchStates.size());
71      }
72      
73  }