01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.chart.service;
17:
18: import org.kuali.core.util.ObjectUtils;
19: import org.kuali.kfs.context.KualiTestBase;
20: import org.kuali.kfs.context.SpringContext;
21: import org.kuali.module.chart.bo.A21SubAccount;
22: import org.kuali.module.chart.bo.SubAccount;
23: import org.kuali.test.ConfigureContext;
24: import org.kuali.test.fixtures.SubAccountFixture;
25:
26: /**
27: * This class tests the SubAccount service.
28: */
29: @ConfigureContext
30: public class SubAccountServiceTest extends KualiTestBase {
31: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
32: .getLogger(SubAccountServiceTest.class);
33:
34: private final static SubAccount subAccount = SubAccountFixture.VALID_SUB_ACCOUNT
35: .createSubAccount();
36:
37: public void testA21SubAccount() {
38: SubAccount sa = SpringContext.getBean(SubAccountService.class)
39: .getByPrimaryId(subAccount.getChartOfAccountsCode(),
40: subAccount.getAccountNumber(),
41: subAccount.getSubAccountNumber());
42:
43: assertTrue("expect to find this sub account: "
44: + subAccount.getChartOfAccountsCode() + "/"
45: + subAccount.getAccountNumber() + "/"
46: + subAccount.getSubAccountNumber(), ObjectUtils
47: .isNotNull(sa));
48: A21SubAccount a21 = sa.getA21SubAccount();
49: assertTrue("expect this to have a21subaccount", ObjectUtils
50: .isNotNull(a21));
51: a21.getIndirectCostRecoveryAccount();
52: }
53:
54: public void testGetByPrimaryId() throws Exception {
55: SubAccount sa = new SubAccount();
56: sa.setAccountNumber(subAccount.getAccountNumber());
57: sa.setChartOfAccountsCode(subAccount.getChartOfAccountsCode());
58: sa.setSubAccountNumber(subAccount.getSubAccountNumber());
59:
60: SubAccount retrieved = SpringContext.getBean(
61: SubAccountService.class).getByPrimaryId(
62: subAccount.getChartOfAccountsCode(),
63: subAccount.getAccountNumber(),
64: subAccount.getSubAccountNumber());
65: assertTrue("Didn't retrieve sub account", ObjectUtils
66: .isNotNull(retrieved));
67: assertEquals("Wrong chart",
68: subAccount.getChartOfAccountsCode(), retrieved
69: .getChartOfAccountsCode());
70: assertEquals("Wrong account", subAccount.getAccountNumber(),
71: retrieved.getAccountNumber());
72: assertEquals("Wrong Sub account number", subAccount
73: .getSubAccountNumber(), retrieved.getSubAccountNumber());
74: }
75:
76: public void testGetByPrimaryIdWithCaching() throws Exception {
77: SubAccount sa = new SubAccount();
78: sa.setAccountNumber(subAccount.getAccountNumber());
79: sa.setChartOfAccountsCode(subAccount.getChartOfAccountsCode());
80: sa.setSubAccountNumber(subAccount.getSubAccountNumber());
81:
82: SubAccount retrieved = SpringContext.getBean(
83: SubAccountService.class).getByPrimaryIdWithCaching(
84: subAccount.getChartOfAccountsCode(),
85: subAccount.getAccountNumber(),
86: subAccount.getSubAccountNumber());
87: assertTrue("Didn't retrieve sub account", ObjectUtils
88: .isNotNull(retrieved));
89: assertEquals("Wrong chart",
90: subAccount.getChartOfAccountsCode(), retrieved
91: .getChartOfAccountsCode());
92: assertEquals("Wrong account", subAccount.getAccountNumber(),
93: retrieved.getAccountNumber());
94: assertEquals("Wrong Sub account number", subAccount
95: .getSubAccountNumber(), retrieved.getSubAccountNumber());
96: }
97:
98: }
|