1 /**
2 * Copyright 2005-2014 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.krad.service;
17
18 import org.junit.Test;
19 import org.kuali.rice.kns.service.KNSServiceLocator;
20 import org.kuali.rice.krad.test.KRADTestCase;
21
22 import static org.junit.Assert.assertTrue;
23
24 /**
25 * tests {@link org.kuali.rice.kns.service.MaintenanceDocumentDictionaryService}
26 */
27 public class MaintenanceDocumentDictionaryServiceTest extends KRADTestCase {
28
29 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(MaintenanceDocumentDictionaryServiceTest.class);
30
31 /**
32 * tests to make sure <code>IllegalArgumentExceptions</code> are being thrown on null parameters
33 */
34 @Test public void testGetFieldDefaultValue_NullArguments() {
35
36 boolean exceptionThrown;
37
38 // test the boClass null argument
39 exceptionThrown = false;
40 try {
41 KNSServiceLocator.getMaintenanceDocumentDictionaryService().getFieldDefaultValue((Class) null, "accountNumber");
42 }
43 catch (IllegalArgumentException e) {
44 exceptionThrown = true;
45 }
46 catch (Exception e) {
47 exceptionThrown = false;
48 }
49 assertTrue("An IllegalArgumentException should have been thrown.", exceptionThrown);
50
51 // test the docTypeName null argument
52 exceptionThrown = false;
53 try {
54 KNSServiceLocator.getMaintenanceDocumentDictionaryService().getFieldDefaultValue((String) null, "accountNumber");
55 }
56 catch (IllegalArgumentException e) {
57 exceptionThrown = true;
58 }
59 catch (Exception e) {
60 exceptionThrown = false;
61 }
62 assertTrue("An IllegalArgumentException should have been thrown.", exceptionThrown);
63
64 // test the fieldName null argument
65 exceptionThrown = false;
66 try {
67 KNSServiceLocator.getMaintenanceDocumentDictionaryService().getFieldDefaultValue("docTypeName", null);
68 }
69 catch (IllegalArgumentException e) {
70 exceptionThrown = true;
71 }
72 catch (Exception e) {
73 exceptionThrown = false;
74 }
75 assertTrue("An IllegalArgumentException should have been thrown.", exceptionThrown);
76 }
77
78 // @Test public void testGetFieldDefaultValue_Account() {
79 //
80 // String result;
81 // result = KRADServiceLocatorInternal.getMaintenanceDocumentDictionaryService().getFieldDefaultValue(AccountManager.class, "defaultType");
82 // LOG.debug(result);
83 // assertEquals("Standard", result);
84 //
85 // }
86 //
87 // @Test public void testGetFieldDefaultValue_SubAccount() {
88 //
89 // String result;
90 // result = KRADServiceLocatorInternal.getMaintenanceDocumentDictionaryService().getFieldDefaultValue(SubAccount.class, "subAccountActiveIndicator");
91 // LOG.debug(result);
92 // assertEquals("true", result);
93 //
94 // result = KRADServiceLocatorInternal.getMaintenanceDocumentDictionaryService().getFieldDefaultValue(SubAccount.class, "a21SubAccount.subAccountTypeCode");
95 // LOG.debug(result);
96 // assertEquals("EX", result);
97 //
98 // result = KRADServiceLocatorInternal.getMaintenanceDocumentDictionaryService().getFieldDefaultValue(SubAccount.class, "a21SubAccount.offCampusCode");
99 // LOG.debug(result);
100 // assertEquals("false", result);
101 //
102 // }
103 //
104 // @Test public void testGetFieldDefaultValue_SubObjectCode() {
105 //
106 // String result;
107 //
108 // result = KRADServiceLocatorInternal.getMaintenanceDocumentDictionaryService().getFieldDefaultValue(SubObjCd.class, "universityFiscalYear");
109 // LOG.debug(result);
110 // assertEquals(getValueFromFinder(FiscalYearFinder.class), result);
111 //
112 // result = KRADServiceLocatorInternal.getMaintenanceDocumentDictionaryService().getFieldDefaultValue(SubObjCd.class, "financialSubObjectActiveIndicator");
113 // LOG.debug(result);
114 // assertEquals("true", result);
115 //
116 // }
117 //
118 // private String getValueFromFinder(Class finderClass) {
119 //
120 // ValueFinder valueFinder = null;
121 // try {
122 // valueFinder = (ValueFinder) finderClass.newInstance();
123 // }
124 // catch (InstantiationException e) {
125 // e.printStackTrace();
126 // assertTrue("An InstantiationException should not have been thrown.", false);
127 // }
128 // catch (IllegalAccessException e) {
129 // e.printStackTrace();
130 // assertTrue("An IllegalAccessException should not have been thrown.", false);
131 // }
132 //
133 // assertNotNull("The valueFinder object should not be null.", valueFinder);
134 //
135 // return valueFinder.getValue();
136 // }
137 }