View Javadoc

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