View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.coa.service;
20  
21  import org.kuali.kfs.coa.businessobject.Account;
22  import org.kuali.kfs.sys.ConfigureContext;
23  import org.kuali.kfs.sys.context.KualiTestBase;
24  import org.kuali.kfs.sys.context.SpringContext;
25  import org.kuali.rice.kim.api.identity.Person;
26  
27  /**
28   * This class tests the Account service.
29   */
30  @ConfigureContext
31  public class AccountServiceTest extends KualiTestBase {
32      org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountServiceTest.class);
33  
34      public void testValidateAccount() {
35          Account account = null;
36          account = SpringContext.getBean(AccountService.class).getByPrimaryId("BA", "6044900");
37          assertNotNull(account);
38          // assertNotNull(account.getSubAccounts());
39          // assertEquals("sub account list should contain 27 subaccounts", 27, account.getSubAccounts().size());
40  
41          account = null;
42          account = SpringContext.getBean(AccountService.class).getByPrimaryId("XX", "0000000");
43          assertNull(account);
44  
45          account = null;
46          account = SpringContext.getBean(AccountService.class).getByPrimaryId("KO", "");
47          assertNull(account);
48  
49          account = null;
50          account = SpringContext.getBean(AccountService.class).getByPrimaryId("UA", null);
51          assertNull(account);
52  
53          account = null;
54          account = SpringContext.getBean(AccountService.class).getByPrimaryId(null, "1912610");
55          assertNull(account);
56  
57          account = null;
58          account = SpringContext.getBean(AccountService.class).getByPrimaryId(null, null);
59          assertNull(account);
60      }
61  
62      /**
63       * This method tests whether a person has "responsibility" for certain accounts, which in turn determines if said user can edit
64       * such accounts later.
65       */
66      // TODO this test uses hardcoded tests...how do we move to fixtures
67      public void testAccountResponsibility() {
68              Person rorenfro = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).getPersonByPrincipalName("rorenfro");
69              Person jaraujo = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).getPersonByPrincipalName("jaraujo");
70              Person rmunroe = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).getPersonByPrincipalName("rmunroe");
71              Person kcopley = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).getPersonByPrincipalName("kcopley");
72  
73              Account bl1031400 = SpringContext.getBean(AccountService.class).getByPrimaryId("BL", "1031400");
74              Account ba9021104 = SpringContext.getBean(AccountService.class).getByPrimaryId("BA", "9021104");
75  
76              // 1. rorenfro is fiscal officer for BL-1031400, so she has responsibility
77              assertTrue(SpringContext.getBean(AccountService.class).hasResponsibilityOnAccount(rorenfro, bl1031400));
78              // 2. JARAUJO is account supervisor for BL-1031400...no responsibility
79              assertFalse(SpringContext.getBean(AccountService.class).hasResponsibilityOnAccount(jaraujo, bl1031400));
80              // 3. RMUNROE is a delegate of BA-901104...has responsibility
81              assertTrue(SpringContext.getBean(AccountService.class).hasResponsibilityOnAccount(rmunroe, ba9021104));
82              // 4. kcopley is not a delegate or fiscal officer of BL-1031400...no responsibility
83              assertFalse(SpringContext.getBean(AccountService.class).hasResponsibilityOnAccount(kcopley, bl1031400));
84      }
85  }
86