1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
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  
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  
40  
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  
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  
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  
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  
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  
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 
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 }