01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: *
19: */package edu.iu.uis.eden.engine.node;
20:
21: import java.util.List;
22:
23: import org.junit.Test;
24: import org.kuali.workflow.test.WorkflowTestCase;
25:
26: /**
27: *
28: * Tests on functionality within the Branch class.
29: *
30: */
31: public class BranchTest extends WorkflowTestCase {
32:
33: private Branch branch;
34:
35: public BranchTest() {
36: super ();
37: }
38:
39: @Test
40: public void testBranchStateIsLazyLoadable() {
41: branch = new Branch();
42: List<BranchState> branchStates = branch.getBranchState();
43: assertNotNull("new branchStates should not be null",
44: branchStates);
45: assertEquals("new branchStates should be empty", 0,
46: branchStates.size());
47:
48: // it should fail with out of bounds error if you try to access an invalid
49: // index directly on the get() method of the List, as we're not using a lazy list
50: boolean errorThrown = false;
51: try {
52: branchStates.get(0);
53: } catch (IndexOutOfBoundsException e) {
54: errorThrown = true;
55: }
56: assertTrue(
57: "An IndexOutOfBoundsException should have been thrown",
58: errorThrown);
59:
60: // it should not fail if using the getBranchStates(int index) method
61: errorThrown = false;
62: try {
63: branch.getDocBranchState(0);
64: } catch (Exception e) {
65: errorThrown = true;
66: }
67: assertFalse("No exception should have been thrown", errorThrown);
68: assertEquals(
69: "There should now be one element in the list (empty)",
70: 1, branchStates.size());
71: }
72:
73: }
|