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.module.chart.service;
017:
018: import java.lang.reflect.InvocationTargetException;
019: import java.util.List;
020: import java.util.Map;
021:
022: import org.apache.commons.beanutils.PropertyUtils;
023: import org.kuali.core.util.ObjectUtils;
024: import org.kuali.kfs.context.KualiTestBase;
025: import org.kuali.kfs.context.SpringContext;
026: import org.kuali.module.chart.bo.ObjectCode;
027: import org.kuali.test.ConfigureContext;
028:
029: /**
030: * This class tests the ObjectCode service.
031: */
032: @ConfigureContext
033: public class ObjectCodeServiceTest extends KualiTestBase {
034: public static final String CHART_CODE = TestConstants.Data4.CHART_CODE;
035:
036: public void testPropertyUtilsDescribe()
037: throws IllegalAccessException, InvocationTargetException,
038: NoSuchMethodException {
039: ObjectCode objectCode = new ObjectCode();
040: Map boProps = PropertyUtils.describe(objectCode);
041: }
042:
043: public void testGetYersList() {
044: ObjectCode objectCode = new ObjectCode();
045: // objectCode = ObjectCodeDao.
046: List list = SpringContext.getBean(ObjectCodeService.class)
047: .getYearList("BL", "5050");
048: assertNotNull("interface garuentee not returning Null", list);
049:
050: assertTrue("expect more than one result", list.size() > 0);
051:
052: }
053:
054: public void testGetYersListEmpty() {
055: ObjectCode objectCode = new ObjectCode();
056: // objectCode = ObjectCodeDao.
057: List list = SpringContext.getBean(ObjectCodeService.class)
058: .getYearList("BL", "asdfasdf");
059: assertNotNull("interface garuentee not returning Null", list);
060: assertTrue("expect more than one result", list.size() == 0);
061:
062: }
063:
064: public void testFindById() {
065: ObjectCode objectCode = SpringContext.getBean(
066: ObjectCodeService.class).getByPrimaryId(
067: new Integer(2004), CHART_CODE, "5000");
068: assertNotNull(objectCode);
069: }
070:
071: public void testFindById2() {
072: ObjectCode objectCode = SpringContext.getBean(
073: ObjectCodeService.class).getByPrimaryId(
074: new Integer(2006), CHART_CODE, "none");
075: assertNull(objectCode);
076: }
077:
078: public void testObjectTypeRetrieval() {
079: ObjectCode objectCode = SpringContext.getBean(
080: ObjectCodeService.class).getByPrimaryId(
081: new Integer(2004), CHART_CODE, "5000");
082: assertTrue("ObjectType Object should be valid.", ObjectUtils
083: .isNotNull(objectCode.getFinancialObjectType()));
084: assertEquals("Object Type should be EE", objectCode
085: .getFinancialObjectType().getCode(), "EX");
086: }
087:
088: public void testObjectSubTypeRetrieval() {
089: ObjectCode objectCode = SpringContext.getBean(
090: ObjectCodeService.class).getByPrimaryId(
091: new Integer(2004), CHART_CODE, "5000");
092: assertTrue("ObjSubTyp Object should be valid.", ObjectUtils
093: .isNotNull(objectCode.getFinancialObjectSubType()));
094: assertEquals("Object Type", "NA", objectCode
095: .getFinancialObjectSubType().getCode());
096: }
097:
098: public void testBudgetAggregationCodeRetrieval() {
099: ObjectCode objectCode = SpringContext.getBean(
100: ObjectCodeService.class).getByPrimaryId(
101: new Integer(2004), CHART_CODE, "5000");
102: assertTrue("BudgetAggregationCode Object should be valid.",
103: ObjectUtils.isNotNull(objectCode
104: .getFinancialBudgetAggregation()));
105: assertEquals("Budget Aggregation Code should be something",
106: objectCode.getFinancialBudgetAggregation().getCode(),
107: "O");
108: }
109:
110: public void testMandatoryTransferEliminationCodeRetrieval() {
111: ObjectCode objectCode = SpringContext.getBean(
112: ObjectCodeService.class).getByPrimaryId(
113: new Integer(2004), CHART_CODE, "5000");
114: assertTrue(
115: "MandatoryTransferEliminationCode Object should be valid.",
116: ObjectUtils.isNotNull(objectCode
117: .getFinObjMandatoryTrnfrelim()));
118: assertEquals(
119: "Mandatory Transfer Elimination Code should be something",
120: objectCode.getFinObjMandatoryTrnfrelim().getCode(), "N");
121: }
122:
123: public void testFederalFundedCodeRetrieval() {
124: ObjectCode objectCode = SpringContext.getBean(
125: ObjectCodeService.class).getByPrimaryId(
126: new Integer(2004), CHART_CODE, "5000");
127: assertTrue("FederalFundedCode Object should be valid.",
128: ObjectUtils.isNotNull(objectCode
129: .getFinancialFederalFunded()));
130: assertEquals("Federal Funded Code should be something",
131: objectCode.getFinancialFederalFunded().getCode(), "N");
132: }
133: }
|