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


001:        /*
002:         * Copyright 2005-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.document;
017:
018:        import static org.kuali.module.financial.document.AccountingDocumentTestUtils.saveDocument;
019:        import static org.kuali.module.financial.document.AccountingDocumentTestUtils.testGetNewDocument_byDocumentClass;
020:        import static org.kuali.test.fixtures.AccountingLineFixture.LINE7;
021:        import static org.kuali.test.fixtures.UserNameFixture.CSWINSON;
022:        import static org.kuali.test.fixtures.UserNameFixture.HSCHREIN;
023:        import static org.kuali.test.fixtures.UserNameFixture.MYLARGE;
024:        import static org.kuali.test.fixtures.UserNameFixture.VPUTMAN;
025:
026:        import java.sql.Date;
027:        import java.util.ArrayList;
028:        import java.util.Calendar;
029:        import java.util.List;
030:
031:        import junit.framework.Assert;
032:
033:        import org.kuali.core.document.Document;
034:        import org.kuali.core.service.DataDictionaryService;
035:        import org.kuali.core.service.DateTimeService;
036:        import org.kuali.core.service.DocumentService;
037:        import org.kuali.core.util.GlobalVariables;
038:        import org.kuali.core.util.KualiDecimal;
039:        import org.kuali.kfs.bo.SourceAccountingLine;
040:        import org.kuali.kfs.bo.TargetAccountingLine;
041:        import org.kuali.kfs.context.KualiTestBase;
042:        import org.kuali.kfs.context.SpringContext;
043:        import org.kuali.kfs.document.AccountingDocument;
044:        import org.kuali.module.financial.bo.DisbursementVoucherNonResidentAlienTax;
045:        import org.kuali.module.financial.bo.DisbursementVoucherPayeeDetail;
046:        import org.kuali.test.ConfigureContext;
047:        import org.kuali.test.DocumentTestUtils;
048:        import org.kuali.test.fixtures.AccountingLineFixture;
049:        import org.kuali.workflow.WorkflowTestUtils;
050:
051:        import edu.iu.uis.eden.EdenConstants;
052:
053:        /**
054:         * This class is used to test DisbursementVoucherDocument.
055:         */
056:        @ConfigureContext(session=HSCHREIN)
057:        // @RelatesTo(RelatesTo.JiraIssue.KULRNE5908)
058:        public class DisbursementVoucherDocumentTest extends KualiTestBase {
059:
060:            public static final Class<DisbursementVoucherDocument> DOCUMENT_CLASS = DisbursementVoucherDocument.class;
061:            // The set of Route Nodes that the test document will progress through
062:
063:            private static final String ACCOUNT_REVIEW = "Account Review";
064:            private static final String ORG_REVIEW = "Org Review";
065:            private static final String CAMPUS_CODE = "Campus Code";
066:
067:            public final void testConvertIntoCopy_clear_additionalCodeInvalidPayee()
068:                    throws Exception {
069:                GlobalVariables.setMessageList(new ArrayList());
070:                DisbursementVoucherDocument dvParameter = (DisbursementVoucherDocument) getDocumentParameterFixture();
071:                DisbursementVoucherDocument document = (DisbursementVoucherDocument) getDocumentParameterFixture();
072:                document.getDvPayeeDetail().setDisbVchrPayeeIdNumber("1234");
073:                document.toCopy();
074:
075:                // the dvParameter doc number needs to be resynced
076:                dvParameter.setDocumentNumber(document.getDocumentNumber());
077:                dvParameter.setDisbVchrContactPhoneNumber("");
078:                dvParameter.setDisbVchrContactEmailId("");
079:                dvParameter.getDvPayeeDetail().setDisbVchrPayeePersonName("");
080:                dvParameter.getDvPayeeDetail().setDisbVchrPayeeLine1Addr("");
081:                dvParameter.getDvPayeeDetail().setDisbVchrPayeeLine2Addr("");
082:                dvParameter.getDvPayeeDetail().setDisbVchrPayeeCityName("");
083:                dvParameter.getDvPayeeDetail().setDisbVchrPayeeStateCode("");
084:                dvParameter.getDvPayeeDetail().setDisbVchrPayeeZipCode("");
085:                dvParameter.getDvPayeeDetail().setDisbVchrPayeeCountryCode("");
086:                dvParameter.getDvPayeeDetail().setDisbVchrAlienPaymentCode(
087:                        false);
088:                dvParameter
089:                        .setDvNonResidentAlienTax(new DisbursementVoucherNonResidentAlienTax());
090:                dvParameter.setDisbVchrPayeeTaxControlCode("");
091:                dvParameter.getDvPayeeDetail().setDisbVchrPayeeIdNumber("");
092:
093:                dvParameter.setDisbVchrContactPersonName(GlobalVariables
094:                        .getUserSession().getUniversalUser().getPersonName());
095:                // set to tomorrow
096:                Calendar calendar = SpringContext
097:                        .getBean(DateTimeService.class).getCurrentCalendar();
098:                calendar.add(Calendar.DAY_OF_MONTH, 1);
099:                calendar.clear(Calendar.MILLISECOND);
100:                calendar.clear(Calendar.SECOND);
101:                calendar.clear(Calendar.MINUTE);
102:                calendar.clear(Calendar.HOUR);
103:                dvParameter.setDisbursementVoucherDueDate(new Date(calendar
104:                        .getTimeInMillis()));
105:
106:                // clear document time since just want to compare dates
107:                Calendar calendar2 = Calendar.getInstance();
108:                calendar2.setTimeInMillis(document
109:                        .getDisbursementVoucherDueDate().getTime());
110:                calendar2.clear(Calendar.MILLISECOND);
111:                calendar2.clear(Calendar.SECOND);
112:                calendar2.clear(Calendar.MINUTE);
113:                calendar2.clear(Calendar.HOUR);
114:                document.setDisbursementVoucherDueDate(new Date(calendar2
115:                        .getTimeInMillis()));
116:
117:                assertMatch(dvParameter, document);
118:
119:            }
120:
121:            @ConfigureContext(session=HSCHREIN,shouldCommitTransactions=true)
122:            // @RelatesTo(RelatesTo.JiraIssue.KULRNE4834)
123:            public final void testWorkflowRouting() throws Exception {
124:                // save and route the document
125:                Document document = buildDocument();
126:                final String docId = document.getDocumentNumber();
127:                SpringContext.getBean(DocumentService.class).routeDocument(
128:                        document, "routing test doc", null);
129:
130:                WorkflowTestUtils.waitForNodeChange(document
131:                        .getDocumentHeader().getWorkflowDocument(),
132:                        ACCOUNT_REVIEW);
133:
134:                // the document should now be routed to VPUTMAN as Fiscal Officer
135:                changeCurrentUser(VPUTMAN);
136:                document = SpringContext.getBean(DocumentService.class)
137:                        .getByDocumentHeaderId(docId);
138:                assertTrue("At incorrect node.", WorkflowTestUtils.isAtNode(
139:                        document, ACCOUNT_REVIEW));
140:                assertTrue("Document should be enroute.", document
141:                        .getDocumentHeader().getWorkflowDocument()
142:                        .stateIsEnroute());
143:                assertTrue("VPUTMAN should have an approve request.", document
144:                        .getDocumentHeader().getWorkflowDocument()
145:                        .isApprovalRequested());
146:                SpringContext.getBean(DocumentService.class).approveDocument(
147:                        document, "Test approving as VPUTMAN", null);
148:
149:                WorkflowTestUtils.waitForNodeChange(document
150:                        .getDocumentHeader().getWorkflowDocument(), ORG_REVIEW);
151:                // now doc should be in Org Review routing to CSWINSON
152:                changeCurrentUser(CSWINSON);
153:                document = SpringContext.getBean(DocumentService.class)
154:                        .getByDocumentHeaderId(docId);
155:                assertTrue("At incorrect node.", WorkflowTestUtils.isAtNode(
156:                        document, ORG_REVIEW));
157:                assertTrue("CSWINSON should have an approve request.", document
158:                        .getDocumentHeader().getWorkflowDocument()
159:                        .isApprovalRequested());
160:                SpringContext.getBean(DocumentService.class).approveDocument(
161:                        document, "Test approving as CSWINSON", null);
162:
163:                // this is going to skip a bunch of other routing and end up at campus code
164:                WorkflowTestUtils
165:                        .waitForNodeChange(document.getDocumentHeader()
166:                                .getWorkflowDocument(), CAMPUS_CODE);
167:
168:                // doc should be in "Campus Code" routing to MYLARGE
169:                changeCurrentUser(MYLARGE);
170:                document = SpringContext.getBean(DocumentService.class)
171:                        .getByDocumentHeaderId(docId);
172:                assertTrue("At incorrect node.", WorkflowTestUtils.isAtNode(
173:                        document, CAMPUS_CODE));
174:                assertTrue("Should have an approve request.", document
175:                        .getDocumentHeader().getWorkflowDocument()
176:                        .isApprovalRequested());
177:                SpringContext.getBean(DocumentService.class).approveDocument(
178:                        document, "Approve", null);
179:
180:                WorkflowTestUtils.waitForStatusChange(document
181:                        .getDocumentHeader().getWorkflowDocument(),
182:                        EdenConstants.ROUTE_HEADER_FINAL_CD);
183:
184:                changeCurrentUser(VPUTMAN);
185:                document = SpringContext.getBean(DocumentService.class)
186:                        .getByDocumentHeaderId(docId);
187:                assertTrue("Document should now be final.", document
188:                        .getDocumentHeader().getWorkflowDocument()
189:                        .stateIsFinal());
190:            }
191:
192:            private int getExpectedPrePeCount() {
193:                return 2;
194:            }
195:
196:            private Document getDocumentParameterFixture() throws Exception {
197:                DisbursementVoucherDocument document = DocumentTestUtils
198:                        .createDocument(SpringContext
199:                                .getBean(DocumentService.class),
200:                                DisbursementVoucherDocument.class);
201:                DisbursementVoucherPayeeDetail payeeDetail = new DisbursementVoucherPayeeDetail();
202:                payeeDetail.setDisbVchrPayeeIdNumber("P000178071");
203:                payeeDetail.setDisbVchrPayeePersonName("Jerry Neal");
204:                payeeDetail.setDisbVchrPayeeLine1Addr("Poplars 423");
205:                payeeDetail.setDisbVchrPayeeCountryCode("UK");
206:                payeeDetail.setDisbVchrPaymentReasonCode("B");
207:                payeeDetail.setDisbursementVoucherPayeeTypeCode("P");
208:                payeeDetail.setDocumentNumber(document.getDocumentNumber());
209:                // payee detail
210:                document.setDvPayeeDetail(payeeDetail);
211:                // payment info
212:                document.setDisbVchrPaymentMethodCode("P");
213:                document.setDisbursementVoucherDueDate(Date
214:                        .valueOf("2010-01-24"));
215:                document.setDisbursementVoucherDocumentationLocationCode("F");
216:                // contact information
217:                document.setCampusCode("BL");
218:                document.setDisbVchrContactPhoneNumber("8081234567");
219:                document.setDisbVchrContactPersonName("aynalem");
220:                document.setDisbVchrCheckStubText("Test DV Check");
221:
222:                KualiDecimal amount = KualiDecimal.ZERO;
223:                for (AccountingLineFixture fixture : getSourceAccountingLineParametersFromFixtures()) {
224:                    amount = amount.add(fixture.amount);
225:                }
226:                for (AccountingLineFixture fixture : getTargetAccountingLineParametersFromFixtures()) {
227:                    amount = amount.add(fixture.amount);
228:                }
229:                document.setDisbVchrCheckTotalAmount(amount);
230:                return document;
231:            }
232:
233:            private List<AccountingLineFixture> getTargetAccountingLineParametersFromFixtures() {
234:                return new ArrayList<AccountingLineFixture>();
235:            }
236:
237:            private List<AccountingLineFixture> getSourceAccountingLineParametersFromFixtures() {
238:                List<AccountingLineFixture> list = new ArrayList<AccountingLineFixture>();
239:                list.add(LINE7);
240:                return list;
241:            }
242:
243:            private <T extends Document> void assertMatch(T document1,
244:                    T document2) {
245:                AccountingDocumentTestUtils.assertMatch(document1, document2);
246:                DisbursementVoucherDocument d1 = (DisbursementVoucherDocument) document1;
247:                DisbursementVoucherDocument d2 = (DisbursementVoucherDocument) document2;
248:
249:                assertPayeeDetail(d1.getDvPayeeDetail(), d2.getDvPayeeDetail());
250:
251:                Assert.assertEquals(d2.getDisbVchrCheckTotalAmount(), d2
252:                        .getDisbVchrCheckTotalAmount());
253:                Assert.assertEquals(d1.getDisbVchrPaymentMethodCode(), d2
254:                        .getDisbVchrPaymentMethodCode());
255:                Assert.assertEquals(d1.getDisbursementVoucherDueDate(), d2
256:                        .getDisbursementVoucherDueDate());
257:                Assert.assertEquals(d1
258:                        .getDisbursementVoucherDocumentationLocationCode(), d2
259:                        .getDisbursementVoucherDocumentationLocationCode());
260:                Assert.assertEquals(d1.getDisbVchrContactEmailId(), d2
261:                        .getDisbVchrContactEmailId());
262:                Assert.assertEquals(d1.getDisbVchrContactPhoneNumber(), d2
263:                        .getDisbVchrContactPhoneNumber());
264:                Assert.assertEquals(d1.getDisbVchrPayeeTaxControlCode(), d2
265:                        .getDisbVchrPayeeTaxControlCode());
266:                Assert.assertEquals(d1.getDisbVchrContactPersonName(), d2
267:                        .getDisbVchrContactPersonName());
268:            }
269:
270:            private void assertPayeeDetail(DisbursementVoucherPayeeDetail d1,
271:                    DisbursementVoucherPayeeDetail d2) {
272:                Assert.assertEquals(d1.getDisbVchrPayeeIdNumber(), d2
273:                        .getDisbVchrPayeeIdNumber());
274:                Assert.assertEquals(d1.getDisbVchrPayeePersonName(), d2
275:                        .getDisbVchrPayeePersonName());
276:                Assert.assertEquals(d1.getDisbVchrPayeeLine1Addr(), d2
277:                        .getDisbVchrPayeeLine1Addr());
278:                Assert.assertEquals(d1.getDisbVchrPayeeCountryCode(), d2
279:                        .getDisbVchrPayeeCountryCode());
280:                Assert.assertEquals(d1.getDisbVchrPaymentReasonCode(), d2
281:                        .getDisbVchrPaymentReasonCode());
282:            }
283:
284:            public final void testAddAccountingLine() throws Exception {
285:                List<SourceAccountingLine> sourceLines = generateSouceAccountingLines();
286:                List<TargetAccountingLine> targetLines = generateTargetAccountingLines();
287:                int expectedSourceTotal = sourceLines.size();
288:                int expectedTargetTotal = targetLines.size();
289:                AccountingDocumentTestUtils.testAddAccountingLine(
290:                        DocumentTestUtils
291:                                .createDocument(SpringContext
292:                                        .getBean(DocumentService.class),
293:                                        DOCUMENT_CLASS), sourceLines,
294:                        targetLines, expectedSourceTotal, expectedTargetTotal);
295:            }
296:
297:            public final void testGetNewDocument() throws Exception {
298:                testGetNewDocument_byDocumentClass(DOCUMENT_CLASS,
299:                        SpringContext.getBean(DocumentService.class));
300:            }
301:
302:            public final void testConvertIntoCopy_copyDisallowed()
303:                    throws Exception {
304:                AccountingDocumentTestUtils.testConvertIntoCopy_copyDisallowed(
305:                        buildDocument(), SpringContext
306:                                .getBean(DataDictionaryService.class));
307:
308:            }
309:
310:            @ConfigureContext(session=HSCHREIN,shouldCommitTransactions=true)
311:            public final void testRouteDocument() throws Exception {
312:                AccountingDocumentTestUtils.testRouteDocument(buildDocument(),
313:                        SpringContext.getBean(DocumentService.class));
314:            }
315:
316:            @ConfigureContext(session=HSCHREIN,shouldCommitTransactions=true)
317:            public final void testSaveDocument() throws Exception {
318:                // get document parameter
319:                AccountingDocument document = buildDocument();
320:                document.prepareForSave();
321:
322:                // save
323:                saveDocument(document, SpringContext
324:                        .getBean(DocumentService.class));
325:
326:                // retrieve
327:                AccountingDocument result = (AccountingDocument) SpringContext
328:                        .getBean(DocumentService.class).getByDocumentHeaderId(
329:                                document.getDocumentNumber());
330:                // verify
331:                assertMatch(document, result);
332:
333:            }
334:
335:            @ConfigureContext(session=HSCHREIN,shouldCommitTransactions=true)
336:            public final void testConvertIntoCopy() throws Exception {
337:                AccountingDocumentTestUtils.testConvertIntoCopy(
338:                        buildDocument(), SpringContext
339:                                .getBean(DocumentService.class),
340:                        getExpectedPrePeCount());
341:            }
342:
343:            // test util methods
344:            private List<SourceAccountingLine> generateSouceAccountingLines()
345:                    throws Exception {
346:                List<SourceAccountingLine> sourceLines = new ArrayList<SourceAccountingLine>();
347:                // set accountinglines to document
348:                for (AccountingLineFixture sourceFixture : getSourceAccountingLineParametersFromFixtures()) {
349:                    sourceLines.add(sourceFixture.createSourceAccountingLine());
350:                }
351:
352:                return sourceLines;
353:            }
354:
355:            private List<TargetAccountingLine> generateTargetAccountingLines()
356:                    throws Exception {
357:                List<TargetAccountingLine> targetLines = new ArrayList<TargetAccountingLine>();
358:                for (AccountingLineFixture targetFixture : getTargetAccountingLineParametersFromFixtures()) {
359:                    targetLines.add(targetFixture.createTargetAccountingLine());
360:                }
361:
362:                return targetLines;
363:            }
364:
365:            private DisbursementVoucherDocument buildDocument()
366:                    throws Exception {
367:                // put accounting lines into document parameter for later
368:                DisbursementVoucherDocument document = (DisbursementVoucherDocument) getDocumentParameterFixture();
369:
370:                // set accountinglines to document
371:                for (AccountingLineFixture sourceFixture : getSourceAccountingLineParametersFromFixtures()) {
372:                    sourceFixture.addAsSourceTo(document);
373:                }
374:
375:                for (AccountingLineFixture targetFixture : getTargetAccountingLineParametersFromFixtures()) {
376:                    targetFixture.addAsTargetTo(document);
377:                }
378:
379:                return document;
380:            }
381:
382:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.