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