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 java.util.HashMap;
22  
23  import org.kuali.kfs.coa.businessobject.BalanceType;
24  import org.kuali.kfs.sys.ConfigureContext;
25  import org.kuali.kfs.sys.context.KualiTestBase;
26  import org.kuali.kfs.sys.context.SpringContext;
27  import org.kuali.rice.krad.service.BusinessObjectService;
28  
29  /**
30   * This class tests the BalanceType service.
31   */
32  @ConfigureContext
33  public class BalanceTypServiceTest extends KualiTestBase {
34      private static final boolean ACTIVE = true;
35      private static final boolean BAL_TYPE_ENCUMB = true;
36      private static final String BAL_TYPE_CODE = "ZZ";
37      private static final String BAL_TYPE_NAME = "Z NAME";
38      private static final String GUID = "123456789012345678901234567890123456";
39      private static final Long VER_NBR = new Long(1);
40      private static final boolean OFFSET_GEN = false;
41      private static final String SHORT_NAME = "Z SHORT";
42  
43      private static final String ACTUAL_BAL_TYPE_CODE = "AC";
44  
45      public void testCreateLookupDelete1() {
46          // create
47          BalanceType bal = new BalanceType();
48          bal.setActive(true);
49          bal.setFinBalanceTypeEncumIndicator(true);
50          bal.setCode(BAL_TYPE_CODE);
51          bal.setName(BAL_TYPE_NAME);
52          bal.setObjectId(GUID);
53          bal.setFinancialOffsetGenerationIndicator(OFFSET_GEN);
54          bal.setFinancialBalanceTypeShortNm(SHORT_NAME);
55          bal.setVersionNumber(VER_NBR);
56  
57          SpringContext.getBean(BusinessObjectService.class).save(bal);
58  
59          // lookup
60          HashMap map = new HashMap();
61          map.put("code", BAL_TYPE_CODE);
62          BalanceType bal2 = (BalanceType) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(BalanceType.class, map);
63          assertNotNull("Should be a valid object.", bal2);
64          assertEquals("Known-good code results in expected returned Name.", BAL_TYPE_NAME, bal2.getName());
65  
66          // delete
67          SpringContext.getBean(BusinessObjectService.class).delete(bal2);
68  
69          // try to lookup again
70          map = new HashMap();
71          map.put("code", BAL_TYPE_CODE);
72          BalanceType bal3 = (BalanceType) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(BalanceType.class, map);
73          assertNull("Shouldn't be a valid object.", bal3);
74      }
75  
76      /*
77       * Disable this test because no data in database yet RO 9-22-05 public void testActualBalanceTypeLookup() { //test known-good
78       * byCode BalanceTyp bal = SpringContext.getBean(BalanceTypService.class).getActualBalanceTyp(); assertNotNull("Should be a
79       * valid object.", bal); assertEquals(ACTUAL_BAL_TYPE_CODE, bal.getCode()); }
80       */
81  }