View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.maintainable;
17  
18  import org.junit.Before;
19  import org.junit.Test;
20  import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
21  import org.kuali.rice.kns.maintenance.Maintainable;
22  import org.kuali.test.KNSTestCase;
23  
24  /**
25   * Test methods for default Kuali maintainable implementation.
26   */
27  public class KualiMaintainableTest extends KNSTestCase {
28      Maintainable maintainable = null;
29  
30      /**
31       * @see org.kuali.rice.test.RiceTestCase#setUp()
32       */
33      @Before
34      public void setUp() throws Exception {
35          super.setUp();
36          maintainable = new KualiMaintainableImpl();
37      }
38  
39      /**
40       * Tests the retrieval of the inactive record display setting when it has not been set (default). Default
41       * should be false according to specification.
42       */
43      @Test
44      public void testGetShowInactiveRecords_Default() throws Exception {
45          boolean displayInactive = maintainable.getShowInactiveRecords("fooCollection");
46          assertTrue("display setting returned true for unset collection", displayInactive);
47      }
48      
49      /**
50       * Tests method throws an exception when given name is null.
51       */
52      @Test
53      public void testGetShowInactiveRecords_NullParam() throws Exception {
54          boolean failedAsExpected = false;
55          try {
56              maintainable.getShowInactiveRecords(null);
57          }
58          catch (IllegalArgumentException expected) {
59              failedAsExpected = true;
60          }
61          
62          assertTrue("exception not thrown for null collection name", failedAsExpected);
63      }
64      
65      /**
66       * Tests setting to display inactive records for a collection.
67       */
68      @Test
69      public void testSetShowInactiveRecords_DisplayCollectionInActive() throws Exception {
70          maintainable.setShowInactiveRecords("collection1", true);
71          assertTrue("state failure on set inactive display to true", maintainable.getShowInactiveRecords("collection1"));
72      }
73      
74      /**
75       * Tests setting to not display inactive records for a collection.
76       */
77      @Test
78      public void testSetShowInactiveRecords_NoDisplayCollectionInActive() throws Exception {
79          maintainable.setShowInactiveRecords("collection1", false);
80          assertFalse("state failure on set inactive display to false", maintainable.getShowInactiveRecords("collection1"));
81      }
82      
83      /**
84       * Tests setting to display inactive records for a sub-collection.
85       */
86      @Test
87      public void testSetShowInactiveRecords_DisplaySubCollectionInActive() throws Exception {
88          maintainable.setShowInactiveRecords("collection1.subCollection", true);
89          assertTrue("state failure on set inactive display to true", maintainable.getShowInactiveRecords("collection1.subCollection"));
90      }
91      
92      /**
93       * Tests setting to not display inactive records for a sub-collection.
94       */
95      @Test
96      public void testSetShowInactiveRecords_NoDisplaySubCollectionInActive() throws Exception {
97          maintainable.setShowInactiveRecords("collection1.subCollection", false);
98          assertFalse("state failure on set inactive display to false", maintainable.getShowInactiveRecords("collection1.subCollection"));
99      }
100     
101     /**
102      * Tests method throws an exception when given name is null.
103      */
104     @Test
105     public void testSetShowInactiveRecords_NullParam() throws Exception {
106         boolean failedAsExpected = false;
107         try {
108             maintainable.setShowInactiveRecords(null, true);
109         }
110         catch (IllegalArgumentException expected) {
111             failedAsExpected = true;
112         }
113         
114         assertTrue("exception not thrown for null collection name", failedAsExpected);
115     }
116 }