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