Source Code Cross Referenced for BalanceServiceTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » service » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.module.financial.service 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-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.financial.service;
017:
018:        import java.util.List;
019:
020:        import org.kuali.core.util.KualiDecimal;
021:        import org.kuali.core.util.UnitTestSqlDao;
022:        import org.kuali.kfs.context.KualiTestBase;
023:        import org.kuali.kfs.context.SpringContext;
024:        import org.kuali.module.chart.bo.Account;
025:        import org.kuali.module.chart.bo.Chart;
026:        import org.kuali.module.gl.service.BalanceService;
027:        import org.kuali.test.ConfigureContext;
028:
029:        /**
030:         * various tests for BalanceService, especially as it supports Account business rules; using hardcoded SQL for bootstrapping
031:         */
032:        @ConfigureContext
033:        public class BalanceServiceTest extends KualiTestBase {
034:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
035:                    .getLogger(BalanceServiceTest.class);
036:            private final static String ACCOUNT_NUMBER = "6812735";
037:            private final static String CHART = "UA";
038:            private final static String SUB_ACCT_NUMBER = "sub";
039:            private final static String SUB_OBJECT_CODE = "123";
040:
041:            private static String DELETE_BALANCES = "delete from GL_BALANCE_T where ";
042:            private static String RAW_BALANCES = "select * from GL_BALANCE_T where ";
043:            private static String INSERT_BALANCE = "insert into GL_BALANCE_T(FIN_COA_CD,ACCOUNT_NBR,SUB_ACCT_NBR,UNIV_FISCAL_YR,FIN_SUB_OBJ_CD,FIN_OBJECT_CD,FIN_BALANCE_TYP_CD,FIN_OBJ_TYP_CD,FIN_BEG_BAL_LN_AMT,ACLN_ANNL_BAL_AMT) values('"
044:                    + CHART
045:                    + "','"
046:                    + ACCOUNT_NUMBER
047:                    + "','"
048:                    + SUB_ACCT_NUMBER
049:                    + "',";
050:
051:            private static boolean runOnce = true;
052:
053:            private static Account account = new Account();
054:            static {
055:                account.setAccountNumber(ACCOUNT_NUMBER);
056:                account.setChartOfAccountsCode(CHART);
057:                // jkeller: added Chart object since now used by the BalanceServiceImpl class.
058:                Chart chart = new Chart();
059:                chart.setFundBalanceObjectCode("9899");
060:                chart.setChartOfAccountsCode(CHART);
061:                account.setChartOfAccounts(chart);
062:            }
063:
064:            private UnitTestSqlDao unitTestSqlDao;
065:
066:            /**
067:             * This method performs all the setup steps necessary to run the tests within this test case.
068:             * 
069:             * @see junit.framework.TestCase#setUp()
070:             */
071:            @Override
072:            protected void setUp() throws Exception {
073:                super .setUp();
074:                unitTestSqlDao = SpringContext.getBean(UnitTestSqlDao.class);
075:                Integer fiscalYear = SpringContext.getBean(
076:                        UniversityDateService.class).getCurrentFiscalYear();
077:
078:                if (runOnce) {
079:                    DELETE_BALANCES += "UNIV_FISCAL_YR=" + fiscalYear
080:                            + " AND ACCOUNT_NBR='" + ACCOUNT_NUMBER + "'";
081:                    RAW_BALANCES += "UNIV_FISCAL_YR=" + fiscalYear
082:                            + " AND ACCOUNT_NBR='" + ACCOUNT_NUMBER + "'";
083:                    INSERT_BALANCE += fiscalYear + ",";
084:                    runOnce = false; // do not run again
085:                }
086:
087:            }
088:
089:            /**
090:             * 
091:             * This method creates and makes and SQL command call to perform and insert passing in the provided parameters.
092:             * @param objectTypeCode The object type code to be inserted.
093:             * @param balanceTypeCode The balance type code to be inserted.
094:             * @param objectCode The object code to be inserted.
095:             * @param beginningAmount The beginning amount to be inserted.
096:             * @param finalAmount The final amount to be inserted.
097:             */
098:            private void insertBalance(String objectTypeCode,
099:                    String balanceTypeCode, String objectCode,
100:                    KualiDecimal beginningAmount, KualiDecimal finalAmount) {
101:                unitTestSqlDao.sqlCommand(INSERT_BALANCE + "'"
102:                        + SUB_OBJECT_CODE + "','" + objectCode + "','"
103:                        + balanceTypeCode + "','" + objectTypeCode + "',"
104:                        + beginningAmount + "," + finalAmount + ")");
105:            }
106:
107:            /**
108:             * 
109:             * This method generates and calls and SQL command to remove all test data from the database.
110:             */
111:            public void purgeTestData() {
112:                unitTestSqlDao.sqlCommand(DELETE_BALANCES);
113:
114:                List results = unitTestSqlDao.sqlSelect(RAW_BALANCES);
115:                assertNotNull("List shouldn't be null", results);
116:                assertEquals("Should return 0 results", 0, results.size());
117:
118:            }
119:
120:            /**
121:             * 
122:             * This method tests that the net result of of balance inserts is zero for appropriate balance type codes.
123:             */
124:            public void testNetToZero() {
125:                List results;
126:                purgeTestData();
127:
128:                assertTrue("should net to zero when no rows exist",
129:                        SpringContext.getBean(BalanceService.class)
130:                                .fundBalanceWillNetToZero(account));
131:
132:                insertBalance("EE", "TR", "9899", new KualiDecimal(1.5),
133:                        new KualiDecimal(2.5));
134:                results = unitTestSqlDao.sqlSelect(RAW_BALANCES);
135:                assertNotNull("List shouldn't be null", results);
136:                assertEquals("Should return 1 result", 1, results.size());
137:
138:                assertTrue("should net to zero with non-AC balance Type Code",
139:                        SpringContext.getBean(BalanceService.class)
140:                                .fundBalanceWillNetToZero(account));
141:
142:                insertBalance("CH", "AC", "9899", new KualiDecimal(1.5),
143:                        new KualiDecimal(2.5));
144:                assertFalse(SpringContext.getBean(BalanceService.class)
145:                        .fundBalanceWillNetToZero(account));
146:
147:                // Negate the income balance with an equal expense balance
148:                insertBalance("EE", "AC", "9899", new KualiDecimal(2),
149:                        new KualiDecimal(2));
150:                assertTrue(
151:                        "should net to zero after adding corresponding expenses",
152:                        SpringContext.getBean(BalanceService.class)
153:                                .fundBalanceWillNetToZero(account));
154:                purgeTestData();
155:            }
156:
157:            /**
158:             *
159:             * This method tests that appropriate asset object codes yield asset liability fund balances while non-asset codes do not.
160:             */
161:            public void testHasAssetLiabilityFundBalanceBalances() {
162:                List results;
163:                purgeTestData();
164:                assertFalse("no rows means no balances", SpringContext.getBean(
165:                        BalanceService.class)
166:                        .hasAssetLiabilityFundBalanceBalances(account));
167:                String fundBalanceObjectCode = "9899"; // TODO - get this from Service? Or System Options?
168:                insertBalance("LI", "AC", "9899", new KualiDecimal(1.5),
169:                        new KualiDecimal(2.5));
170:                assertFalse("should ignore 9899 balance", SpringContext
171:                        .getBean(BalanceService.class)
172:                        .hasAssetLiabilityFundBalanceBalances(account));
173:                insertBalance("LI", "AC", "9900", new KualiDecimal(1.5),
174:                        new KualiDecimal(2.5));
175:                assertTrue("expect nonzero balance for non-9899 balance",
176:                        SpringContext.getBean(BalanceService.class)
177:                                .hasAssetLiabilityFundBalanceBalances(account));
178:
179:            }
180:
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.