Source Code Cross Referenced for LaborOriginEntryServiceTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » 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.labor.service 
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.service;
017:
018:        import static org.kuali.module.gl.bo.OriginEntrySource.LABOR_MAIN_POSTER_VALID;
019:
020:        import java.sql.Date;
021:        import java.util.ArrayList;
022:        import java.util.Arrays;
023:        import java.util.Iterator;
024:        import java.util.List;
025:        import java.util.Map;
026:        import java.util.Properties;
027:
028:        import org.apache.commons.lang.StringUtils;
029:        import org.kuali.core.service.BusinessObjectService;
030:        import org.kuali.core.service.DateTimeService;
031:        import org.kuali.core.util.KualiDecimal;
032:        import org.kuali.kfs.KFSPropertyConstants;
033:        import org.kuali.kfs.context.KualiTestBase;
034:        import org.kuali.kfs.context.SpringContext;
035:        import org.kuali.module.gl.bo.OriginEntryGroup;
036:        import org.kuali.module.gl.service.OriginEntryGroupService;
037:        import org.kuali.module.gl.util.LedgerEntryHolder;
038:        import org.kuali.module.gl.util.PosterOutputSummaryEntry;
039:        import org.kuali.module.gl.web.TestDataGenerator;
040:        import org.kuali.module.labor.bo.LaborOriginEntry;
041:        import org.kuali.module.labor.util.ObjectUtil;
042:        import org.kuali.module.labor.util.TestDataPreparator;
043:        import org.kuali.test.ConfigureContext;
044:
045:        @ConfigureContext
046:        public class LaborOriginEntryServiceTest extends KualiTestBase {
047:
048:            private Properties properties;
049:            private String fieldNames;
050:            private String deliminator;
051:            private OriginEntryGroup group1, group2;
052:            private Map fieldValues;
053:
054:            private LaborOriginEntryService laborOriginEntryService;
055:            private OriginEntryGroupService originEntryGroupService;
056:            private BusinessObjectService businessObjectService;
057:
058:            @Override
059:            public void setUp() throws Exception {
060:                super .setUp();
061:                String messageFileName = "test/src/org/kuali/module/labor/testdata/message.properties";
062:                String propertiesFileName = "test/src/org/kuali/module/labor/testdata/laborOriginEntryService.properties";
063:
064:                properties = (new TestDataGenerator(propertiesFileName,
065:                        messageFileName)).getProperties();
066:                fieldNames = properties.getProperty("fieldNames");
067:                deliminator = properties.getProperty("deliminator");
068:
069:                laborOriginEntryService = SpringContext
070:                        .getBean(LaborOriginEntryService.class);
071:                originEntryGroupService = SpringContext
072:                        .getBean(OriginEntryGroupService.class);
073:                businessObjectService = SpringContext
074:                        .getBean(BusinessObjectService.class);
075:
076:                Date today = (SpringContext.getBean(DateTimeService.class))
077:                        .getCurrentSqlDate();
078:                group1 = originEntryGroupService.createGroup(today,
079:                        LABOR_MAIN_POSTER_VALID, false, false, false);
080:                group2 = originEntryGroupService.createGroup(today,
081:                        LABOR_MAIN_POSTER_VALID, false, false, false);
082:
083:                LaborOriginEntry cleanup = new LaborOriginEntry();
084:                ObjectUtil.populateBusinessObject(cleanup, properties,
085:                        "dataCleanup", fieldNames, deliminator);
086:                fieldValues = ObjectUtil.buildPropertyMap(cleanup, Arrays
087:                        .asList(StringUtils.split(fieldNames, deliminator)));
088:                fieldValues
089:                        .remove(KFSPropertyConstants.TRANSACTION_ENTRY_SEQUENCE_NUMBER);
090:                fieldValues.remove(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
091:                fieldValues
092:                        .remove(KFSPropertyConstants.TRANSACTION_DEBIT_CREDIT_CODE);
093:                businessObjectService.deleteMatching(LaborOriginEntry.class,
094:                        fieldValues);
095:            }
096:
097:            public void testGetEntriesByGroup() throws Exception {
098:                int numberOfTestData = Integer.valueOf(properties
099:                        .getProperty("getEntriesByGroup.numOfData"));
100:                int expectedNumber = Integer.valueOf(properties
101:                        .getProperty("getEntriesByGroup.expectedNumOfData"));
102:
103:                businessObjectService
104:                        .save(getInputDataList("getEntriesByGroup.testData",
105:                                numberOfTestData, group1));
106:                List<LaborOriginEntry> entries = convertIteratorAsList(laborOriginEntryService
107:                        .getEntriesByGroup(group1));
108:                assertEquals(expectedNumber, entries.size());
109:
110:                businessObjectService.save(getInputDataList(
111:                        "getEntriesByGroup.testData", numberOfTestData - 1,
112:                        group2));
113:                entries = convertIteratorAsList(laborOriginEntryService
114:                        .getEntriesByGroup(group1));
115:                assertEquals(expectedNumber, entries.size());
116:            }
117:
118:            public void testGetEntriesByGroups() throws Exception {
119:                int numberOfTestData = Integer.valueOf(properties
120:                        .getProperty("getEntriesByGroups.numOfData"));
121:                int expectedNumber = Integer.valueOf(properties
122:                        .getProperty("getEntriesByGroups.expectedNumOfData"));
123:
124:                List<OriginEntryGroup> groups = new ArrayList<OriginEntryGroup>();
125:                groups.add(group1);
126:                businessObjectService
127:                        .save(getInputDataList("getEntriesByGroups.testData",
128:                                numberOfTestData, group1));
129:                List<LaborOriginEntry> entries = convertIteratorAsList(laborOriginEntryService
130:                        .getEntriesByGroups(groups));
131:                assertEquals(expectedNumber, entries.size());
132:
133:                groups.add(group2);
134:                businessObjectService.save(getInputDataList(
135:                        "getEntriesByGroups.testData", numberOfTestData - 1,
136:                        group2));
137:                entries = convertIteratorAsList(laborOriginEntryService
138:                        .getEntriesByGroups(groups));
139:                assertEquals(expectedNumber + expectedNumber - 1, entries
140:                        .size());
141:            }
142:
143:            public void testGetConsolidatedEntriesByGroup() throws Exception {
144:                int numberOfTestData = Integer
145:                        .valueOf(properties
146:                                .getProperty("getConsolidatedEntriesByGroup.numOfData"));
147:                int expectedNumber = Integer
148:                        .valueOf(properties
149:                                .getProperty("getConsolidatedEntriesByGroup.expectedNumOfData"));
150:                KualiDecimal expectedTotal1 = new KualiDecimal(
151:                        properties
152:                                .getProperty("getConsolidatedEntriesByGroup.expectedTotal1"));
153:                KualiDecimal expectedTotal2 = new KualiDecimal(
154:                        properties
155:                                .getProperty("getConsolidatedEntriesByGroup.expectedTotal2"));
156:
157:                businessObjectService.save(getInputDataList(
158:                        "getConsolidatedEntriesByGroup.testData",
159:                        numberOfTestData, group1));
160:                List<LaborOriginEntry> entries = convertIteratorAsList(laborOriginEntryService
161:                        .getEntriesByGroup(group1, true));
162:                assertEquals(expectedNumber, entries.size());
163:                assertEquals(expectedTotal1, entries.get(0)
164:                        .getTransactionLedgerEntryAmount());
165:                assertEquals(expectedTotal2, entries.get(1)
166:                        .getTransactionLedgerEntryAmount());
167:
168:                businessObjectService.save(getInputDataList(
169:                        "getConsolidatedEntriesByGroup.testData",
170:                        numberOfTestData, group2));
171:                entries = convertIteratorAsList(laborOriginEntryService
172:                        .getEntriesByGroup(group1, true));
173:                assertEquals(expectedNumber, entries.size());
174:                assertEquals(expectedTotal1, entries.get(0)
175:                        .getTransactionLedgerEntryAmount());
176:                assertEquals(expectedTotal2, entries.get(1)
177:                        .getTransactionLedgerEntryAmount());
178:            }
179:
180:            public void testGetSummariedEntriesByGroups() throws Exception {
181:                int numberOfTestData = Integer.valueOf(properties
182:                        .getProperty("getSummariedEntriesByGroups.numOfData"));
183:                int expectedNumber = Integer
184:                        .valueOf(properties
185:                                .getProperty("getSummariedEntriesByGroups.expectedNumOfData"));
186:
187:                List<OriginEntryGroup> groups = new ArrayList<OriginEntryGroup>();
188:                LedgerEntryHolder ledgerEntryHolder = laborOriginEntryService
189:                        .getSummariedEntriesByGroups(groups);
190:                assertTrue(ledgerEntryHolder.getLedgerEntries().isEmpty());
191:
192:                groups.add(group1);
193:                businessObjectService.save(getInputDataList(
194:                        "getSummariedEntriesByGroups.testData",
195:                        numberOfTestData, group1));
196:                ledgerEntryHolder = laborOriginEntryService
197:                        .getSummariedEntriesByGroups(groups);
198:                assertEquals(expectedNumber, ledgerEntryHolder
199:                        .getLedgerEntries().size());
200:
201:                groups.add(group2);
202:                businessObjectService.save(getInputDataList(
203:                        "getSummariedEntriesByGroups.testData",
204:                        numberOfTestData, group2));
205:                ledgerEntryHolder = laborOriginEntryService
206:                        .getSummariedEntriesByGroups(groups);
207:                assertEquals(expectedNumber, ledgerEntryHolder
208:                        .getLedgerEntries().size());
209:            }
210:
211:            public void testGetPosterOutputSummaryByGroups() throws Exception {
212:                int numberOfTestData = Integer
213:                        .valueOf(properties
214:                                .getProperty("getPosterOutputSummaryByGroups.numOfData"));
215:                int expectedNumber = Integer
216:                        .valueOf(properties
217:                                .getProperty("getPosterOutputSummaryByGroups.expectedNumOfData"));
218:
219:                List<OriginEntryGroup> groups = new ArrayList<OriginEntryGroup>();
220:                Map<String, PosterOutputSummaryEntry> outputSummary = laborOriginEntryService
221:                        .getPosterOutputSummaryByGroups(groups);
222:                assertTrue(outputSummary.isEmpty());
223:
224:                groups.add(group1);
225:                businessObjectService.save(getInputDataList(
226:                        "getPosterOutputSummaryByGroups.testData",
227:                        numberOfTestData, group1));
228:                outputSummary = laborOriginEntryService
229:                        .getPosterOutputSummaryByGroups(groups);
230:                assertEquals(expectedNumber, outputSummary.size());
231:
232:                groups.add(group2);
233:                businessObjectService.save(getInputDataList(
234:                        "getPosterOutputSummaryByGroups.testData",
235:                        numberOfTestData, group2));
236:                outputSummary = laborOriginEntryService
237:                        .getPosterOutputSummaryByGroups(groups);
238:                assertEquals(expectedNumber, outputSummary.size());
239:            }
240:
241:            public void testGetCountOfEntriesInGroups() throws Exception {
242:                int numberOfTestData = Integer.valueOf(properties
243:                        .getProperty("getCountOfEntriesInGroups.numOfData"));
244:                int expectedNumber = Integer
245:                        .valueOf(properties
246:                                .getProperty("getCountOfEntriesInGroups.expectedNumOfData"));
247:
248:                List<OriginEntryGroup> groups = new ArrayList<OriginEntryGroup>();
249:                int count = laborOriginEntryService
250:                        .getCountOfEntriesInGroups(groups);
251:                assertEquals(0, count);
252:
253:                groups.add(group1);
254:                businessObjectService.save(getInputDataList(
255:                        "getCountOfEntriesInGroups.testData", numberOfTestData,
256:                        group1));
257:                count = laborOriginEntryService
258:                        .getCountOfEntriesInGroups(groups);
259:                assertEquals(expectedNumber, count);
260:
261:                groups.add(group2);
262:                businessObjectService.save(getInputDataList(
263:                        "getCountOfEntriesInGroups.testData", numberOfTestData,
264:                        group2));
265:                count = laborOriginEntryService
266:                        .getCountOfEntriesInGroups(groups);
267:                assertEquals(expectedNumber * 2, count);
268:            }
269:
270:            private List getInputDataList(String propertyKeyPrefix,
271:                    int numberOfInputData, OriginEntryGroup group) {
272:                return TestDataPreparator.getLaborOriginEntryList(properties,
273:                        propertyKeyPrefix, numberOfInputData, group);
274:            }
275:
276:            private List<LaborOriginEntry> convertIteratorAsList(
277:                    Iterator<LaborOriginEntry> entries) {
278:                List<LaborOriginEntry> entryList = new ArrayList<LaborOriginEntry>();
279:                while (entries.hasNext()) {
280:                    entryList.add(entries.next());
281:                }
282:                return entryList;
283:            }
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.