Source Code Cross Referenced for DisbursementVoucherTravelServiceTest.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.sql.Timestamp;
019:
020:        import org.kuali.core.service.DateTimeService;
021:        import org.kuali.core.util.KualiDecimal;
022:        import org.kuali.kfs.context.KualiTestBase;
023:        import org.kuali.kfs.context.SpringContext;
024:        import org.kuali.module.financial.document.DisbursementVoucherDocument;
025:        import org.kuali.test.ConfigureContext;
026:
027:        /**
028:         * This class tests the DisbursementVoucherTravel service.
029:         */
030:        @ConfigureContext
031:        public class DisbursementVoucherTravelServiceTest extends KualiTestBase {
032:            private DisbursementVoucherDocument dvDocument;
033:
034:            /**
035:             * Test calculation of per diem.
036:             * 
037:             * @throws Exception
038:             */
039:            public void testCalculatePerDiem() throws Exception {
040:                dvDocument = new DisbursementVoucherDocument();
041:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
042:                        "04/21/2006 0:00 AM");
043:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
044:                        "04/22/2006 0:01 AM");
045:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
046:                        .getDvPerdiemStartDttmStamp(), dvDocument
047:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
048:                        new KualiDecimal(10), new KualiDecimal(12.50));
049:
050:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
051:                        "04/21/2006 10:00 PM");
052:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
053:                        "04/22/2006 5:00 AM");
054:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
055:                        .getDvPerdiemStartDttmStamp(), dvDocument
056:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
057:                        new KualiDecimal(10), new KualiDecimal(0));
058:
059:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
060:                        "04/21/2006 0:00 AM");
061:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
062:                        "04/23/2006 0:01 AM");
063:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
064:                        .getDvPerdiemStartDttmStamp(), dvDocument
065:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
066:                        new KualiDecimal(10), new KualiDecimal(22.50));
067:
068:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
069:                        "04/21/2006 12:01 PM");
070:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
071:                        "04/23/2006 11:59 PM");
072:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
073:                        .getDvPerdiemStartDttmStamp(), dvDocument
074:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
075:                        new KualiDecimal(10), new KualiDecimal(25.00));
076:
077:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
078:                        "04/21/2006 11:59 PM");
079:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
080:                        "04/23/2006 11:59 PM");
081:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
082:                        .getDvPerdiemStartDttmStamp(), dvDocument
083:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
084:                        new KualiDecimal(10), new KualiDecimal(22.50));
085:
086:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
087:                        "04/21/2006 0:00 AM");
088:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
089:                        "04/23/2006 12:01 PM");
090:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
091:                        .getDvPerdiemStartDttmStamp(), dvDocument
092:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
093:                        new KualiDecimal(10), new KualiDecimal(30.00));
094:
095:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
096:                        "12/28/2005 0:00 AM");
097:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
098:                        "01/01/2006 0:01 AM");
099:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
100:                        .getDvPerdiemStartDttmStamp(), dvDocument
101:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
102:                        new KualiDecimal(10), new KualiDecimal(42.50));
103:
104:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
105:                        "04/21/2006 1:00 PM");
106:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
107:                        "04/23/2006 0:01 AM");
108:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
109:                        .getDvPerdiemStartDttmStamp(), dvDocument
110:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
111:                        new KualiDecimal(10), new KualiDecimal(17.50));
112:
113:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
114:                        "04/21/2006 6:00 PM");
115:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
116:                        "04/23/2006 0:01 AM");
117:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
118:                        .getDvPerdiemStartDttmStamp(), dvDocument
119:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
120:                        new KualiDecimal(10), new KualiDecimal(15.00));
121:
122:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
123:                        "12/28/2005 0:00 AM");
124:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
125:                        "01/01/2006 6:01 AM");
126:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
127:                        .getDvPerdiemStartDttmStamp(), dvDocument
128:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
129:                        new KualiDecimal(10), new KualiDecimal(45.00));
130:
131:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
132:                        "12/28/2005 0:00 AM");
133:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
134:                        "01/01/2006 11:59 PM");
135:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
136:                        .getDvPerdiemStartDttmStamp(), dvDocument
137:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
138:                        new KualiDecimal(10), new KualiDecimal(50.00));
139:
140:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
141:                        "04/21/2006 0:00 AM");
142:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
143:                        "04/21/2006 11:59 PM");
144:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
145:                        .getDvPerdiemStartDttmStamp(), dvDocument
146:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
147:                        new KualiDecimal(10), new KualiDecimal(7.50));
148:
149:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
150:                        "04/21/2006 3:00 PM");
151:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
152:                        "04/21/2006 6:00 PM");
153:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
154:                        .getDvPerdiemStartDttmStamp(), dvDocument
155:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
156:                        new KualiDecimal(10), new KualiDecimal(0));
157:
158:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
159:                        "04/21/2006 5:00 AM");
160:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
161:                        "04/21/2006 5:00 PM");
162:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
163:                        .getDvPerdiemStartDttmStamp(), dvDocument
164:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
165:                        new KualiDecimal(10), new KualiDecimal(0.00));
166:
167:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
168:                        "04/21/2006 4:59 AM");
169:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
170:                        "04/21/2006 5:00 PM");
171:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
172:                        .getDvPerdiemStartDttmStamp(), dvDocument
173:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
174:                        new KualiDecimal(10), new KualiDecimal(5.00));
175:
176:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
177:                        "04/21/2006 1:00 AM");
178:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
179:                        "04/21/2006 7:01 PM");
180:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
181:                        .getDvPerdiemStartDttmStamp(), dvDocument
182:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
183:                        new KualiDecimal(50), new KualiDecimal(37.50));
184:
185:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
186:                        "04/21/2006 11:59 PM");
187:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
188:                        "04/22/2006 6:00 AM");
189:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
190:                        .getDvPerdiemStartDttmStamp(), dvDocument
191:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
192:                        new KualiDecimal(10), new KualiDecimal(0));
193:
194:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
195:                        "04/21/2006 6:01 PM");
196:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
197:                        "04/22/2006 5:59 AM");
198:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
199:                        .getDvPerdiemStartDttmStamp(), dvDocument
200:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
201:                        new KualiDecimal(10), new KualiDecimal(5.00));
202:
203:                dvDocument.getDvNonEmployeeTravel().setPerDiemStartDateTime(
204:                        "04/21/2006 3:00 PM");
205:                dvDocument.getDvNonEmployeeTravel().setPerDiemEndDateTime(
206:                        "04/22/2006 6:01 AM");
207:                runPerDiemTest(dvDocument.getDvNonEmployeeTravel()
208:                        .getDvPerdiemStartDttmStamp(), dvDocument
209:                        .getDvNonEmployeeTravel().getDvPerdiemEndDttmStamp(),
210:                        new KualiDecimal(10), new KualiDecimal(10));
211:
212:            }
213:
214:            private void runPerDiemTest(Timestamp startTime, Timestamp endTime,
215:                    KualiDecimal perDiemRate, KualiDecimal expectedPerDiemAmount) {
216:                assertEquals("Per diem amount not correct ",
217:                        expectedPerDiemAmount, SpringContext.getBean(
218:                                DisbursementVoucherTravelService.class)
219:                                .calculatePerDiemAmount(startTime, endTime,
220:                                        perDiemRate));
221:            }
222:
223:            /**
224:             * Tests the calculation of travel mileage amount. This is testing against the mileage rates defined currently, we need to find
225:             * a way to fix this for when they change: 0-500 0.375 500-3000 0.18 3000 - 0
226:             * 
227:             * @throws Exception
228:             */
229:            public void testCalculateMileageAmount() throws Exception {
230:                Timestamp effectiveDate = SpringContext.getBean(
231:                        DateTimeService.class).getCurrentTimestamp();
232:
233:                runMileageAmountTest(new Integer(0), new KualiDecimal(0),
234:                        effectiveDate);
235:                runMileageAmountTest(new Integer(1), new KualiDecimal(.38),
236:                        effectiveDate);
237:                runMileageAmountTest(new Integer(10), new KualiDecimal(3.75),
238:                        effectiveDate);
239:                runMileageAmountTest(new Integer(15), new KualiDecimal(5.63),
240:                        effectiveDate);
241:                runMileageAmountTest(new Integer(100), new KualiDecimal(37.5),
242:                        effectiveDate);
243:                runMileageAmountTest(new Integer(200), new KualiDecimal(75.00),
244:                        effectiveDate);
245:                runMileageAmountTest(new Integer(380), new KualiDecimal(142.5),
246:                        effectiveDate);
247:                runMileageAmountTest(new Integer(500), new KualiDecimal(187.5),
248:                        effectiveDate);
249:
250:                runMileageAmountTest(new Integer(501),
251:                        new KualiDecimal(187.68), effectiveDate);
252:                runMileageAmountTest(new Integer(600), new KualiDecimal(205.5),
253:                        effectiveDate);
254:                runMileageAmountTest(new Integer(2500),
255:                        new KualiDecimal(547.5), effectiveDate);
256:                runMileageAmountTest(new Integer(3000),
257:                        new KualiDecimal(637.5), effectiveDate);
258:
259:                runMileageAmountTest(new Integer(3001),
260:                        new KualiDecimal(637.5), effectiveDate);
261:                runMileageAmountTest(new Integer(8000),
262:                        new KualiDecimal(637.5), effectiveDate);
263:            }
264:
265:            private void runMileageAmountTest(Integer totalMiles,
266:                    KualiDecimal expectedMileageAmount, Timestamp effectiveDate) {
267:                assertEquals("Mileage amount not correct ",
268:                        expectedMileageAmount, SpringContext.getBean(
269:                                DisbursementVoucherTravelService.class)
270:                                .calculateMileageAmount(totalMiles,
271:                                        effectiveDate));
272:            }
273:
274:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.