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 org.kuali.core.bo.user.UniversalUser;
019: import org.kuali.core.exceptions.UserNotFoundException;
020: import org.kuali.core.service.UniversalUserService;
021: import org.kuali.kfs.context.KualiTestBase;
022: import org.kuali.kfs.context.SpringContext;
023: import org.kuali.module.chart.bo.Account;
024: import org.kuali.test.ConfigureContext;
025:
026: /**
027: * This class tests the Account service.
028: */
029: @ConfigureContext
030: public class AccountServiceTest extends KualiTestBase {
031: org.apache.log4j.Logger LOG = org.apache.log4j.Logger
032: .getLogger(AccountServiceTest.class);
033:
034: public void testValidateAccount() {
035: Account account = null;
036: account = SpringContext.getBean(AccountService.class)
037: .getByPrimaryId("BA", "6044900");
038: assertNotNull(account);
039: // assertNotNull(account.getSubAccounts());
040: // assertEquals("sub account list should contain 27 subaccounts", 27, account.getSubAccounts().size());
041:
042: account = null;
043: account = SpringContext.getBean(AccountService.class)
044: .getByPrimaryId("XX", "0000000");
045: assertNull(account);
046:
047: account = null;
048: account = SpringContext.getBean(AccountService.class)
049: .getByPrimaryId("KO", "");
050: assertNull(account);
051:
052: account = null;
053: account = SpringContext.getBean(AccountService.class)
054: .getByPrimaryId("UA", null);
055: assertNull(account);
056:
057: account = null;
058: account = SpringContext.getBean(AccountService.class)
059: .getByPrimaryId(null, "1912610");
060: assertNull(account);
061:
062: account = null;
063: account = SpringContext.getBean(AccountService.class)
064: .getByPrimaryId(null, null);
065: assertNull(account);
066: }
067:
068: /**
069: * This method tests whether a person has "responsibility" for certain accounts, which in turn determines if said user can edit
070: * such accounts later.
071: */
072: // TODO this test uses hardcoded tests...how do we move to fixtures
073: public void testAccountResponsibility() {
074: try {
075: UniversalUser rorenfro = SpringContext.getBean(
076: UniversalUserService.class)
077: .getUniversalUserByAuthenticationUserId("rorenfro");
078: UniversalUser jaraujo = SpringContext.getBean(
079: UniversalUserService.class)
080: .getUniversalUserByAuthenticationUserId("jaraujo");
081: UniversalUser rmunroe = SpringContext.getBean(
082: UniversalUserService.class)
083: .getUniversalUserByAuthenticationUserId("rmunroe");
084: UniversalUser kcopley = SpringContext.getBean(
085: UniversalUserService.class)
086: .getUniversalUserByAuthenticationUserId("kcopley");
087:
088: Account bl1031400 = SpringContext.getBean(
089: AccountService.class).getByPrimaryId("BL",
090: "1031400");
091: Account ba9021104 = SpringContext.getBean(
092: AccountService.class).getByPrimaryId("BA",
093: "9021104");
094:
095: // 1. RORENFRO is fiscal officer for BL-1031400, so she has responsibility
096: assertTrue(SpringContext.getBean(AccountService.class)
097: .hasResponsibilityOnAccount(rorenfro, bl1031400));
098: // 2. JARAUJO is account supervisor for BL-1031400...no responsibility
099: assertFalse(SpringContext.getBean(AccountService.class)
100: .hasResponsibilityOnAccount(jaraujo, bl1031400));
101: // 3. RMUNROE is a delegate of BA-901104...has responsibility
102: assertTrue(SpringContext.getBean(AccountService.class)
103: .hasResponsibilityOnAccount(rmunroe, ba9021104));
104: // 4. KCOPLEY is not a delegate or fiscal officer of BL-1031400...no responsibility
105: assertFalse(SpringContext.getBean(AccountService.class)
106: .hasResponsibilityOnAccount(kcopley, bl1031400));
107: } catch (UserNotFoundException e) {
108: // TODO Auto-generated catch block
109: e.printStackTrace();
110: }
111: }
112: }
|