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.core.datadictionary;
017:
018: import org.junit.Before;
019: import org.junit.Test;
020: import org.kuali.rice.KNSServiceLocator;
021: import org.kuali.test.KNSTestBase;
022: import org.kuali.test.KNSWithTestSpringContext;
023:
024: /**
025: * ValidationCompletionUtilsTest
026: *
027: *
028: */
029: @KNSWithTestSpringContext
030: public class ValidationCompletionUtilsTest extends KNSTestBase {
031:
032: private ValidationCompletionUtils validationCompletionUtils;
033:
034: @Before
035: public void setUp() throws Exception {
036: super .setUp();
037: if (null == validationCompletionUtils) {
038: validationCompletionUtils = KNSServiceLocator
039: .getValidationCompletionUtils();
040: }
041: }
042:
043: @Test
044: public void testIsBusinessObjectClass_nullClass() {
045: boolean failedAsExpected = false;
046:
047: try {
048: validationCompletionUtils.isBusinessObjectClass(null);
049: } catch (IllegalArgumentException e) {
050: failedAsExpected = true;
051: }
052:
053: assertTrue(failedAsExpected);
054: }
055:
056: @Test
057: public void testIsBusinessObjectClass_nonBusinessObjectClass() {
058: assertFalse(validationCompletionUtils
059: .isBusinessObjectClass(java.lang.String.class));
060: }
061:
062: // @Test
063: // public void testIsBusinessObjectClass_businessObjectClass() {
064: // assertTrue(validationCompletionUtils.isBusinessObjectClass(org.kuali.module.chart.bo.ProjectCode.class));
065: // }
066:
067: @Test
068: public void testIsMaintainableClass_nullClass() {
069: boolean failedAsExpected = false;
070:
071: try {
072: validationCompletionUtils.isMaintainableClass(null);
073: } catch (IllegalArgumentException e) {
074: failedAsExpected = true;
075: }
076:
077: assertTrue(failedAsExpected);
078: }
079:
080: @Test
081: public void testIsMaintainableClass_nonMaintainableClass() {
082: assertFalse(validationCompletionUtils
083: .isMaintainableClass(java.lang.String.class));
084: }
085:
086: @Test
087: public void testIsDocumentClass_nullClass() {
088: boolean failedAsExpected = false;
089:
090: try {
091: validationCompletionUtils.isDocumentClass(null);
092: } catch (IllegalArgumentException e) {
093: failedAsExpected = true;
094: }
095:
096: assertTrue(failedAsExpected);
097: }
098:
099: @Test
100: public void testIsDocumentClass_nonDocumentClass() {
101: assertFalse(validationCompletionUtils
102: .isDocumentClass(java.lang.String.class));
103: }
104:
105: // @Test
106: // public void testIsDocumentClass_documentClass() {
107: // assertTrue(validationCompletionUtils.isDocumentClass(org.kuali.module.financial.document.InternalBillingDocument.class));
108: // }
109:
110: @Test
111: public void testIsDescendentClass_nullDescendentClass() {
112: boolean failedAsExpected = false;
113:
114: try {
115: validationCompletionUtils.isDescendentClass(null,
116: java.lang.String.class);
117: } catch (IllegalArgumentException e) {
118: failedAsExpected = true;
119: }
120:
121: assertTrue(failedAsExpected);
122: }
123:
124: @Test
125: public void testIsDescendentClass_nullAncestorClass() {
126: boolean failedAsExpected = false;
127:
128: try {
129: validationCompletionUtils.isDescendentClass(
130: java.lang.String.class, null);
131: } catch (IllegalArgumentException e) {
132: failedAsExpected = true;
133: }
134:
135: assertTrue(failedAsExpected);
136: }
137:
138: @Test
139: public void testIsDescendentClass_nonDescendentClass() {
140: assertFalse(validationCompletionUtils.isDescendentClass(
141: java.lang.Object.class, java.lang.String.class));
142: }
143:
144: @Test
145: public void testIsDescendentClass_descendentClass() {
146: assertTrue(validationCompletionUtils.isDescendentClass(
147: java.util.List.class, java.util.Collection.class));
148: }
149:
150: @Test
151: public void testIsPropertyOf_nullClass() {
152: boolean failedAsExpected = false;
153:
154: try {
155: validationCompletionUtils.isPropertyOf(null, "foo");
156: } catch (IllegalArgumentException e) {
157: failedAsExpected = true;
158: }
159:
160: assertTrue(failedAsExpected);
161: }
162:
163: @Test
164: public void testIsPropertyOf_blankPropertyName() {
165: boolean failedAsExpected = false;
166:
167: try {
168: validationCompletionUtils.isPropertyOf(
169: java.lang.String.class, "");
170: } catch (IllegalArgumentException e) {
171: failedAsExpected = true;
172: }
173:
174: assertTrue(failedAsExpected);
175: }
176:
177: @Test
178: public void testIsPropertyOf_unknownProperty() {
179: assertFalse(validationCompletionUtils.isPropertyOf(
180: java.lang.String.class, "foo"));
181: }
182:
183: // @Test
184: // public void testIsPropertyOf_knownProperty() {
185: // assertTrue(validationCompletionUtils.isPropertyOf(org.kuali.module.chart.bo.ProjectCode.class, "name"));
186: // }
187:
188: @Test
189: public void testIsCollectionPropertyOf_nullClass() {
190: boolean failedAsExpected = false;
191:
192: try {
193: validationCompletionUtils.isCollectionPropertyOf(null,
194: "foo");
195: } catch (IllegalArgumentException e) {
196: failedAsExpected = true;
197: }
198:
199: assertTrue(failedAsExpected);
200: }
201:
202: @Test
203: public void testIsCollectionPropertyOf_blankPropertyName() {
204: boolean failedAsExpected = false;
205:
206: try {
207: validationCompletionUtils.isCollectionPropertyOf(
208: java.lang.String.class, "");
209: } catch (IllegalArgumentException e) {
210: failedAsExpected = true;
211: }
212:
213: assertTrue(failedAsExpected);
214: }
215:
216: @Test
217: public void testIsCollectionPropertyOf_unknownProperty() {
218: assertFalse(validationCompletionUtils.isCollectionPropertyOf(
219: java.lang.String.class, "foo"));
220: }
221:
222: // @Test
223: // public void testIsCollectionPropertyOf_nonCollectionProperty() {
224: // assertFalse(validationCompletionUtils.isCollectionPropertyOf(org.kuali.module.financial.document.InternalBillingDocument.class, "nextItemLineNumber"));
225: // }
226: //
227: // @Test
228: // public void testIsCollectionPropertyOf_collectionProperty() {
229: // assertTrue(validationCompletionUtils.isCollectionPropertyOf(org.kuali.module.financial.document.InternalBillingDocument.class, "items"));
230: // }
231: }
|