Source Code Cross Referenced for LaborOriginEntryTestBase.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » 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.labor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 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.labor;
017:
018:        import java.io.PrintStream;
019:        import java.math.BigDecimal;
020:        import java.util.Collection;
021:        import java.util.Date;
022:        import java.util.Iterator;
023:        import java.util.List;
024:        import java.util.Map;
025:
026:        import org.kuali.core.service.ConfigurableDateService;
027:        import org.kuali.core.service.KualiConfigurationService;
028:        import org.kuali.core.service.PersistenceService;
029:        import org.kuali.core.util.UnitTestSqlDao;
030:        import org.kuali.kfs.KFSConstants;
031:        import org.kuali.kfs.context.KualiTestBase;
032:        import org.kuali.kfs.context.SpringContext;
033:        import org.kuali.kfs.context.TestUtils;
034:        import org.kuali.module.chart.bo.OffsetDefinition;
035:        import org.kuali.module.financial.bo.Bank;
036:        import org.kuali.module.gl.bo.OriginEntryGroup;
037:        import org.kuali.module.gl.dao.OriginEntryDao;
038:        import org.kuali.module.gl.service.OriginEntryGroupService;
039:        import org.kuali.module.labor.bo.LaborOriginEntry;
040:        import org.kuali.module.labor.dao.LaborOriginEntryDao;
041:        import org.kuali.module.labor.service.LaborOriginEntryService;
042:
043:        public class LaborOriginEntryTestBase extends KualiTestBase {
044:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
045:                    .getLogger(LaborOriginEntryTestBase.class);
046:
047:            protected ConfigurableDateService dateTimeService;
048:            protected PersistenceService persistenceService;
049:            protected UnitTestSqlDao unitTestSqlDao = null;
050:            protected OriginEntryGroupService originEntryGroupService = null;
051:            protected LaborOriginEntryService laborOriginEntryService = null;
052:
053:            protected OriginEntryDao originEntryDao = null;
054:            protected LaborOriginEntryDao laborOriginEntryDao = null;
055:            protected KualiConfigurationService kualiConfigurationService = null;
056:            protected Date date;
057:
058:            public LaborOriginEntryTestBase() {
059:                super ();
060:            }
061:
062:            @Override
063:            protected void setUp() throws Exception {
064:                super .setUp();
065:
066:                LOG.debug("setUp() starting");
067:
068:                dateTimeService = SpringContext
069:                        .getBean(ConfigurableDateService.class);
070:                date = dateTimeService.getCurrentDate();
071:
072:                // Other objects needed for the tests
073:                persistenceService = SpringContext
074:                        .getBean(PersistenceService.class);
075:                unitTestSqlDao = SpringContext.getBean(UnitTestSqlDao.class);
076:                laborOriginEntryService = SpringContext
077:                        .getBean(LaborOriginEntryService.class);
078:
079:                originEntryDao = SpringContext.getBean(OriginEntryDao.class);
080:                laborOriginEntryDao = SpringContext
081:                        .getBean(LaborOriginEntryDao.class);
082:
083:                originEntryGroupService = SpringContext
084:                        .getBean(OriginEntryGroupService.class);
085:                kualiConfigurationService = SpringContext
086:                        .getBean(KualiConfigurationService.class);
087:
088:                // Set all enhancements to off
089:                resetAllEnhancementFlags();
090:            }
091:
092:            protected class EntryHolder {
093:                public String groupCode;
094:                public String transactionLine;
095:
096:                public EntryHolder(String groupCode, String transactionLine) {
097:                    this .groupCode = groupCode;
098:                    this .transactionLine = transactionLine;
099:                }
100:            }
101:
102:            protected void loadInputTransactions(String groupCode,
103:                    String[] transactions, Date date) {
104:                OriginEntryGroup group = originEntryGroupService.createGroup(
105:                        new java.sql.Date(date.getTime()), groupCode, true,
106:                        true, true);
107:                loadTransactions(transactions, group);
108:            }
109:
110:            protected void loadInputTransactions(String groupCode,
111:                    String[] transactions) {
112:                OriginEntryGroup group = originEntryGroupService.createGroup(
113:                        new java.sql.Date(dateTimeService.getCurrentDate()
114:                                .getTime()), groupCode, true, true, true);
115:                loadTransactions(transactions, group);
116:            }
117:
118:            protected void loadTransactions(String[] transactions,
119:                    OriginEntryGroup group) {
120:                for (int i = 0; i < transactions.length; i++) {
121:                    LaborOriginEntry loe = new LaborOriginEntry(transactions[i]);
122:                    laborOriginEntryService.createEntry(loe, group);
123:                }
124:
125:                persistenceService.clearCache();
126:            }
127:
128:            protected void clearExpenditureTable() {
129:                unitTestSqlDao.sqlCommand("delete from gl_expend_trn_t");
130:            }
131:
132:            protected void clearSufficientFundBalanceTable() {
133:                unitTestSqlDao.sqlCommand("delete from gl_sf_balances_t");
134:            }
135:
136:            protected void clearGlEntryTable(String fin_coa_cd,
137:                    String account_nbr) {
138:                unitTestSqlDao
139:                        .sqlCommand("delete from gl_entry_t where fin_coa_cd = '"
140:                                + fin_coa_cd
141:                                + "' and account_nbr = '"
142:                                + account_nbr + "'");
143:            }
144:
145:            protected void clearReversalTable() {
146:                unitTestSqlDao.sqlCommand("delete from gl_reversal_t");
147:            }
148:
149:            protected void clearGlBalanceTable() {
150:                unitTestSqlDao.sqlCommand("delete from gl_balance_t");
151:            }
152:
153:            protected void clearEncumbranceTable() {
154:                unitTestSqlDao.sqlCommand("delete from gl_encumbrance_t");
155:            }
156:
157:            protected void clearGlAccountBalanceTable() {
158:                unitTestSqlDao.sqlCommand("delete from gl_acct_balances_t");
159:            }
160:
161:            protected void clearOriginEntryTables() {
162:                unitTestSqlDao.sqlCommand("delete from ld_lbr_origin_entry_t");
163:                unitTestSqlDao.sqlCommand("delete from gl_origin_entry_grp_t");
164:            }
165:
166:            /**
167:             * Check all the entries in gl_origin_entry_t against the data passed in EntryHolder[]. If any of them are different, assert an
168:             * error.
169:             * 
170:             * @param requiredEntries
171:             */
172:            protected void assertOriginEntries(int groupCount,
173:                    EntryHolder[] requiredEntries) {
174:                persistenceService.clearCache();
175:
176:                List groups = unitTestSqlDao
177:                        .sqlSelect("select * from gl_origin_entry_grp_t order by origin_entry_grp_src_cd");
178:                assertEquals("Number of groups is wrong", groupCount, groups
179:                        .size());
180:
181:                Collection c = laborOriginEntryDao.testingLaborGetAllEntries();
182:
183:                // This is for debugging purposes - change to true for output
184:                if (true) {
185:                    for (Iterator iter = groups.iterator(); iter.hasNext();) {
186:                        Map element = (Map) iter.next();
187:                        System.err.println("G:"
188:                                + element.get("ORIGIN_ENTRY_GRP_ID") + " "
189:                                + element.get("ORIGIN_ENTRY_GRP_SRC_CD"));
190:                    }
191:
192:                    for (Iterator iter = c.iterator(); iter.hasNext();) {
193:                        LaborOriginEntry element = (LaborOriginEntry) iter
194:                                .next();
195:                        System.err.println("L:" + element.getEntryGroupId()
196:                                + " " + element.getLine());
197:                    }
198:                }
199:
200:                assertEquals("Wrong number of transactions in Origin Entry",
201:                        requiredEntries.length, c.size());
202:
203:                int count = 0;
204:                for (Iterator iter = c.iterator(); iter.hasNext();) {
205:                    LaborOriginEntry foundTransaction = (LaborOriginEntry) iter
206:                            .next();
207:
208:                    // Check group
209:                    int group = getGroup(groups,
210:                            requiredEntries[count].groupCode);
211:
212:                    assertEquals("Group for transaction "
213:                            + foundTransaction.getEntryId() + " is wrong",
214:                            group, foundTransaction.getEntryGroupId()
215:                                    .intValue());
216:
217:                    // Check transaction - this is done this way so that Anthill prints the two transactions to make
218:                    // resolving the issue easier.
219:
220:                    // This test is not good for Labor because input and output is little different. -- Amount data
221:                    /*
222:                     * String expected = requiredEntries[count].transactionLine.substring(0, 294);// trim(); String found =
223:                     * foundTransaction.getLine().substring(0, 294);// trim(); if (!found.equals(expected)) { System.err.println("Expected
224:                     * transaction: " + expected); System.err.println("Found transaction: " + found); fail("Transaction " +
225:                     * foundTransaction.getEntryId() + " doesn't match expected output"); }
226:                     */
227:                    count++;
228:                }
229:            }
230:
231:            protected int getGroup(List groups, String groupCode) {
232:                for (Iterator iter = groups.iterator(); iter.hasNext();) {
233:                    Map element = (Map) iter.next();
234:
235:                    String sourceCode = (String) element
236:                            .get("ORIGIN_ENTRY_GRP_SRC_CD");
237:                    if (groupCode.equals(sourceCode)) {
238:                        BigDecimal groupId = (BigDecimal) element
239:                                .get("ORIGIN_ENTRY_GRP_ID");
240:                        return groupId.intValue();
241:                    }
242:                }
243:                return -1;
244:            }
245:
246:            protected static Object[] FLEXIBLE_OFFSET_ENABLED_FLAG = {
247:                    OffsetDefinition.class,
248:                    KFSConstants.SystemGroupParameterNames.FLEXIBLE_OFFSET_ENABLED_FLAG };
249:            protected static Object[] FLEXIBLE_CLAIM_ON_CASH_BANK_ENABLED_FLAG = {
250:                    Bank.class,
251:                    KFSConstants.SystemGroupParameterNames.FLEXIBLE_CLAIM_ON_CASH_BANK_ENABLED_FLAG };
252:
253:            protected void resetAllEnhancementFlags() throws Exception {
254:                setApplicationConfigurationFlag(
255:                        (Class) FLEXIBLE_OFFSET_ENABLED_FLAG[0],
256:                        (String) FLEXIBLE_OFFSET_ENABLED_FLAG[1], false);
257:                setApplicationConfigurationFlag(
258:                        (Class) FLEXIBLE_CLAIM_ON_CASH_BANK_ENABLED_FLAG[0],
259:                        (String) FLEXIBLE_CLAIM_ON_CASH_BANK_ENABLED_FLAG[1],
260:                        false);
261:            }
262:
263:            protected void setApplicationConfigurationFlag(
264:                    Class componentClass, String name, boolean value)
265:                    throws Exception {
266:                TestUtils.setSystemParameter(componentClass, name, value ? "Y"
267:                        : "N");
268:            }
269:
270:            protected void traceList(List list, String name) {
271:                trace(
272:                        "StartList " + name + "( " + list.size()
273:                                + " elements): ", 0);
274:
275:                for (Iterator iterator = list.iterator(); iterator.hasNext();) {
276:                    trace(iterator.next(), 1);
277:                }
278:
279:                trace("EndList " + name + ": ", 0);
280:                trace("", 0);
281:            }
282:
283:            protected void trace(Object o, int tabIndentCount) {
284:                PrintStream out = System.out;
285:
286:                for (int i = 0; i < tabIndentCount; i++) {
287:                    out.print("\t");
288:                }
289:
290:                out.println(null == o ? "NULL" : o.toString());
291:            }
292:
293:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.