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  
23  import static org.junit.Assert.assertFalse;
24  import static org.junit.Assert.assertTrue;
25  
26  /**
27   * Test methods for default Kuali maintainable implementation.
28   */
29  public class KualiMaintainableTest {
30      Maintainable maintainable = null;
31  
32  
33      @Before
34      public void setUp() throws Exception {
35          maintainable = new KualiMaintainableImpl();
36      }
37  
38      /**
39       * Tests the retrieval of the inactive record display setting when it has not been set (default). Default
40       * should be false according to specification.
41       */
42      @Test
43      public void testGetShowInactiveRecords_Default() throws Exception {
44          boolean displayInactive = maintainable.getShowInactiveRecords("fooCollection");
45          assertTrue("display setting returned true for unset collection", displayInactive);
46      }
47      
48      /**
49       * Tests method throws an exception when given name is null.
50       */
51      @Test
52      public void testGetShowInactiveRecords_NullParam() throws Exception {
53          boolean failedAsExpected = false;
54          try {
55              maintainable.getShowInactiveRecords(null);
56          }
57          catch (IllegalArgumentException expected) {
58              failedAsExpected = true;
59          }
60          
61          assertTrue("exception not thrown for null collection name", failedAsExpected);
62      }
63      
64      /**
65       * Tests setting to display inactive records for a collection.
66       */
67      @Test
68      public void testSetShowInactiveRecords_DisplayCollectionInActive() throws Exception {
69          maintainable.setShowInactiveRecords("collection1", true);
70          assertTrue("state failure on set inactive display to true", maintainable.getShowInactiveRecords("collection1"));
71      }
72      
73      /**
74       * Tests setting to not display inactive records for a collection.
75       */
76      @Test
77      public void testSetShowInactiveRecords_NoDisplayCollectionInActive() throws Exception {
78          maintainable.setShowInactiveRecords("collection1", false);
79          assertFalse("state failure on set inactive display to false", maintainable.getShowInactiveRecords("collection1"));
80      }
81      
82      /**
83       * Tests setting to display inactive records for a sub-collection.
84       */
85      @Test
86      public void testSetShowInactiveRecords_DisplaySubCollectionInActive() throws Exception {
87          maintainable.setShowInactiveRecords("collection1.subCollection", true);
88          assertTrue("state failure on set inactive display to true", maintainable.getShowInactiveRecords("collection1.subCollection"));
89      }
90      
91      /**
92       * Tests setting to not display inactive records for a sub-collection.
93       */
94      @Test
95      public void testSetShowInactiveRecords_NoDisplaySubCollectionInActive() throws Exception {
96          maintainable.setShowInactiveRecords("collection1.subCollection", false);
97          assertFalse("state failure on set inactive display to false", maintainable.getShowInactiveRecords("collection1.subCollection"));
98      }
99      
100     /**
101      * Tests method throws an exception when given name is null.
102      */
103     @Test
104     public void testSetShowInactiveRecords_NullParam() throws Exception {
105         boolean failedAsExpected = false;
106         try {
107             maintainable.setShowInactiveRecords(null, true);
108         }
109         catch (IllegalArgumentException expected) {
110             failedAsExpected = true;
111         }
112         
113         assertTrue("exception not thrown for null collection name", failedAsExpected);
114     }
115 }