001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.rice.maintainable;
017:
018: import org.junit.Before;
019: import org.junit.Test;
020: import org.kuali.core.maintenance.KualiMaintainableImpl;
021: import org.kuali.core.maintenance.Maintainable;
022: import org.kuali.rice.TestBase;
023:
024: /**
025: * Test methods for default Kuali maintainable implementation.
026: */
027: public class KualiMaintainableTest extends TestBase {
028: Maintainable maintainable = null;
029:
030: /**
031: * @see org.kuali.rice.test.RiceTestCase#setUp()
032: */
033: @Before
034: public void setUp() throws Exception {
035: super .setUp();
036: maintainable = new KualiMaintainableImpl();
037: }
038:
039: /**
040: * Tests the retrieval of the inactive record display setting when it has not been set (default). Default
041: * should be false according to specification.
042: */
043: @Test
044: public void testGetShowInactiveRecords_Default() throws Exception {
045: boolean displayInactive = maintainable
046: .getShowInactiveRecords("fooCollection");
047: assertTrue(
048: "display setting returned true for unset collection",
049: displayInactive);
050: }
051:
052: /**
053: * Tests method throws an exception when given name is null.
054: */
055: @Test
056: public void testGetShowInactiveRecords_NullParam() throws Exception {
057: boolean failedAsExpected = false;
058: try {
059: maintainable.getShowInactiveRecords(null);
060: } catch (IllegalArgumentException expected) {
061: failedAsExpected = true;
062: }
063:
064: assertTrue("exception not thrown for null collection name",
065: failedAsExpected);
066: }
067:
068: /**
069: * Tests setting to display inactive records for a collection.
070: */
071: @Test
072: public void testSetShowInactiveRecords_DisplayCollectionInActive()
073: throws Exception {
074: maintainable.setShowInactiveRecords("collection1", true);
075: assertTrue("state failure on set inactive display to true",
076: maintainable.getShowInactiveRecords("collection1"));
077: }
078:
079: /**
080: * Tests setting to not display inactive records for a collection.
081: */
082: @Test
083: public void testSetShowInactiveRecords_NoDisplayCollectionInActive()
084: throws Exception {
085: maintainable.setShowInactiveRecords("collection1", false);
086: assertFalse("state failure on set inactive display to false",
087: maintainable.getShowInactiveRecords("collection1"));
088: }
089:
090: /**
091: * Tests setting to display inactive records for a sub-collection.
092: */
093: @Test
094: public void testSetShowInactiveRecords_DisplaySubCollectionInActive()
095: throws Exception {
096: maintainable.setShowInactiveRecords(
097: "collection1.subCollection", true);
098: assertTrue(
099: "state failure on set inactive display to true",
100: maintainable
101: .getShowInactiveRecords("collection1.subCollection"));
102: }
103:
104: /**
105: * Tests setting to not display inactive records for a sub-collection.
106: */
107: @Test
108: public void testSetShowInactiveRecords_NoDisplaySubCollectionInActive()
109: throws Exception {
110: maintainable.setShowInactiveRecords(
111: "collection1.subCollection", false);
112: assertFalse(
113: "state failure on set inactive display to false",
114: maintainable
115: .getShowInactiveRecords("collection1.subCollection"));
116: }
117:
118: /**
119: * Tests method throws an exception when given name is null.
120: */
121: @Test
122: public void testSetShowInactiveRecords_NullParam() throws Exception {
123: boolean failedAsExpected = false;
124: try {
125: maintainable.setShowInactiveRecords(null, true);
126: } catch (IllegalArgumentException expected) {
127: failedAsExpected = true;
128: }
129:
130: assertTrue("exception not thrown for null collection name",
131: failedAsExpected);
132: }
133: }
|