Source Code Cross Referenced for AccountingLineParserBaseTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » bo » 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.bo 
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.bo;
017:
018:        import static org.kuali.test.fixtures.UserNameFixture.KHUNTLEY;
019:
020:        import java.io.ByteArrayInputStream;
021:        import java.util.Arrays;
022:        import java.util.List;
023:
024:        import org.kuali.core.service.DocumentService;
025:        import org.kuali.core.util.KualiDecimal;
026:        import org.kuali.kfs.KFSKeyConstants;
027:        import org.kuali.kfs.bo.AccountingLineParser;
028:        import org.kuali.kfs.bo.SourceAccountingLine;
029:        import org.kuali.kfs.bo.TargetAccountingLine;
030:        import org.kuali.kfs.context.KualiTestBase;
031:        import org.kuali.kfs.context.SpringContext;
032:        import org.kuali.kfs.document.AccountingDocument;
033:        import org.kuali.kfs.exceptions.AccountingLineParserException;
034:        import org.kuali.module.financial.document.InternalBillingDocument;
035:        import org.kuali.test.ConfigureContext;
036:        import org.kuali.test.suite.AnnotationTestSuite;
037:        import org.kuali.test.suite.CrossSectionSuite;
038:
039:        /**
040:         * Test class for testing <code>{@link AccountingLineParserBase}</code>
041:         */
042:        @AnnotationTestSuite(CrossSectionSuite.class)
043:        @ConfigureContext(session=KHUNTLEY)
044:        public class AccountingLineParserBaseTest extends KualiTestBase {
045:
046:            private AccountingDocument accountingDocument;
047:            private AccountingLineParser parser;
048:
049:            @Override
050:            protected void setUp() throws Exception {
051:                super .setUp();
052:                accountingDocument = (AccountingDocument) SpringContext
053:                        .getBean(DocumentService.class).getNewDocument(
054:                                InternalBillingDocument.class);
055:                parser = accountingDocument.getAccountingLineParser();
056:            }
057:
058:            /**
059:             */
060:            public void testParseSourceAccountingLine_failure_notANumber() {
061:                try {
062:                    parser.parseSourceAccountingLine(accountingDocument,
063:                            "BL,4631672, , ,KUL, , , a");
064:                    fail("didn't throw AccountingLineParserException");
065:                } catch (AccountingLineParserException e) {
066:                    // good
067:                    assertInvalidPropertyValue(e, " a");
068:                }
069:            }
070:
071:            private static void assertInvalidPropertyValue(
072:                    AccountingLineParserException e, String expectedErrorParam) {
073:                assertEquals(
074:                        KFSKeyConstants.AccountingLineParser.ERROR_INVALID_PROPERTY_VALUE,
075:                        e.getErrorKey());
076:                List<String> errorParams = Arrays
077:                        .asList(e.getErrorParameters());
078:                assertTrue(errorParams + " contains '" + expectedErrorParam
079:                        + "'", errorParams.contains(expectedErrorParam));
080:            }
081:
082:            /**
083:             */
084:            public void testParseTargetAccountingLine_failure_notANumber() {
085:                try {
086:                    parser.parseTargetAccountingLine(accountingDocument,
087:                            "BL,4631672, , ,KUL, , , b");
088:                    fail("didn't throw AccountingLineParserException");
089:                } catch (AccountingLineParserException e) {
090:                    // good
091:                    assertInvalidPropertyValue(e, " b");
092:                }
093:            }
094:
095:            /**
096:             */
097:            public void testParseSourceAccountingLine_pass_upperCase() {
098:                String chartOfAccountsCode = "BL";
099:                String accountNumber = "463172";
100:                String projectCode = "KUL";
101:                String amount = "12.31";
102:
103:                StringBuffer sb = new StringBuffer();
104:                sb.append(chartOfAccountsCode);
105:                sb.append(",");
106:                sb.append(accountNumber);
107:                sb.append(",,,,");
108:                sb.append(projectCode);
109:                sb.append(",,");
110:                sb.append(amount);
111:                SourceAccountingLine result = parser.parseSourceAccountingLine(
112:                        accountingDocument, sb.toString());
113:
114:                assertEquals(accountingDocument.getPostingYear(), result
115:                        .getPostingYear());
116:                assertEquals(accountingDocument.getDocumentNumber(), result
117:                        .getDocumentNumber());
118:                assertEquals(accountingDocument.getSourceAccountingLines()
119:                        .size() + 1, result.getSequenceNumber().intValue());
120:                assertEquals(chartOfAccountsCode, result
121:                        .getChartOfAccountsCode());
122:                assertEquals(accountNumber, result.getAccountNumber());
123:                assertEquals(projectCode, result.getProjectCode());
124:                assertEquals(new KualiDecimal(amount), result.getAmount());
125:            }
126:
127:            /**
128:             */
129:            public void testParseSourceAccountingLine_pass_lowerCase() {
130:                String chartOfAccountsCode = "bl";
131:                String accountNumber = "463172";
132:                String projectCode = "kul";
133:                String amount = "12.31";
134:
135:                StringBuffer sb = new StringBuffer();
136:                sb.append(chartOfAccountsCode);
137:                sb.append(",");
138:                sb.append(accountNumber);
139:                sb.append(",,,,");
140:                sb.append(projectCode);
141:                sb.append(",,");
142:                sb.append(amount);
143:                SourceAccountingLine result = parser.parseSourceAccountingLine(
144:                        accountingDocument, sb.toString());
145:
146:                assertEquals(accountingDocument.getPostingYear(), result
147:                        .getPostingYear());
148:                assertEquals(accountingDocument.getDocumentNumber(), result
149:                        .getDocumentNumber());
150:                assertEquals(accountingDocument.getSourceAccountingLines()
151:                        .size() + 1, result.getSequenceNumber().intValue());
152:                assertEquals(chartOfAccountsCode.toUpperCase(), result
153:                        .getChartOfAccountsCode());
154:                assertEquals(accountNumber, result.getAccountNumber());
155:                assertEquals(projectCode.toUpperCase(), result.getProjectCode());
156:                assertEquals(new KualiDecimal(amount), result.getAmount());
157:            }
158:
159:            /**
160:             */
161:            public void testParseTargetAccountingLine_pass_upperCase() {
162:                String chartOfAccountsCode = "BL";
163:                String accountNumber = "463172";
164:                String projectCode = "KUL";
165:                String amount = "12.31";
166:
167:                StringBuffer sb = new StringBuffer();
168:                sb.append(chartOfAccountsCode);
169:                sb.append(",");
170:                sb.append(accountNumber);
171:                sb.append(",,,,");
172:                sb.append(projectCode);
173:                sb.append(",,");
174:                sb.append(amount);
175:                TargetAccountingLine result = parser.parseTargetAccountingLine(
176:                        accountingDocument, sb.toString());
177:
178:                assertEquals(accountingDocument.getPostingYear(), result
179:                        .getPostingYear());
180:                assertEquals(accountingDocument.getDocumentNumber(), result
181:                        .getDocumentNumber());
182:                assertEquals(accountingDocument.getTargetAccountingLines()
183:                        .size() + 1, result.getSequenceNumber().intValue());
184:                assertEquals(chartOfAccountsCode, result
185:                        .getChartOfAccountsCode());
186:                assertEquals(accountNumber, result.getAccountNumber());
187:                assertEquals(projectCode, result.getProjectCode());
188:                assertEquals(new KualiDecimal(amount), result.getAmount());
189:            }
190:
191:            /**
192:             */
193:            public void testParseTargetAccountingLine_pass_lowerCase() {
194:                String chartOfAccountsCode = "bl";
195:                String accountNumber = "463172";
196:                String projectCode = "kul";
197:                String amount = "12.31";
198:
199:                StringBuffer sb = new StringBuffer();
200:                sb.append(chartOfAccountsCode);
201:                sb.append(",");
202:                sb.append(accountNumber);
203:                sb.append(",,,,");
204:                sb.append(projectCode);
205:                sb.append(",,");
206:                sb.append(amount);
207:                TargetAccountingLine result = parser.parseTargetAccountingLine(
208:                        accountingDocument, sb.toString());
209:
210:                assertEquals(accountingDocument.getPostingYear(), result
211:                        .getPostingYear());
212:                assertEquals(accountingDocument.getDocumentNumber(), result
213:                        .getDocumentNumber());
214:                assertEquals(accountingDocument.getTargetAccountingLines()
215:                        .size() + 1, result.getSequenceNumber().intValue());
216:                assertEquals(chartOfAccountsCode.toUpperCase(), result
217:                        .getChartOfAccountsCode());
218:                assertEquals(accountNumber, result.getAccountNumber());
219:                assertEquals(projectCode.toUpperCase(), result.getProjectCode());
220:                assertEquals(new KualiDecimal(amount), result.getAmount());
221:            }
222:
223:            /**
224:             */
225:            public void testImportSourceAccountingLine_pass() {
226:                String chartOfAccountsCode = "bl";
227:                String accountNumber = "463172";
228:                String projectCode = "kul";
229:                String amount = "12.31";
230:
231:                StringBuffer sb = new StringBuffer();
232:                sb.append(chartOfAccountsCode);
233:                sb.append(",");
234:                sb.append(accountNumber);
235:                sb.append(",,,,");
236:                sb.append(projectCode);
237:                sb.append(",,");
238:                sb.append(amount);
239:                List<SourceAccountingLine> lineList = parser
240:                        .importSourceAccountingLines(null,
241:                                new ByteArrayInputStream(sb.toString()
242:                                        .getBytes()), accountingDocument);
243:                for (SourceAccountingLine result : lineList) {
244:                    assertEquals(accountingDocument.getPostingYear(), result
245:                            .getPostingYear());
246:                    assertEquals(accountingDocument.getDocumentNumber(), result
247:                            .getDocumentNumber());
248:                    assertEquals(accountingDocument.getSourceAccountingLines()
249:                            .size() + 1, result.getSequenceNumber().intValue());
250:                    assertEquals(chartOfAccountsCode.toUpperCase(), result
251:                            .getChartOfAccountsCode());
252:                    assertEquals(accountNumber, result.getAccountNumber());
253:                    assertEquals(projectCode.toUpperCase(), result
254:                            .getProjectCode());
255:                    assertEquals(new KualiDecimal(amount), result.getAmount());
256:                }
257:            }
258:            //
259:            // public void testImportSourceAccountingLines() throws Exception {
260:            // List result = null;
261:            // List expected = null;
262:            // TransactionalDocument document = getDocument();
263:            //
264:            // expected = getImportSourceAccountingLinesExpected(document);
265:            // result = getAccountingLineParser().importSourceAccountingLines(getImportSourceAccountingLinesFixture(), document);
266:            // assertTrue((result != null));
267:            // assertEquals(expected.toString(), result.toString());
268:            // }
269:            //
270:            // public void testImportTargetAccountingLines() throws Exception {
271:            // List result = null;
272:            // List expected = null;
273:            // TransactionalDocument document = getDocument();
274:            //
275:            // expected = getImportTargetAccountingLinesExpected(document);
276:            // result = getAccountingLineParser().importTargetAccountingLines(getImportTargetAccountingLinesFixture(), document);
277:            // assertTrue((result != null));
278:            // assertEquals(expected.toString(), result.toString());
279:            // }
280:            //
281:            // /**
282:            // * KULEDOCS-1317
283:            // *
284:            // * @throws Exception
285:            // */
286:            // public void testImportSourceAccountingLines_lowerCase() throws Exception {
287:            // StringBuffer buffer = new
288:            // StringBuffer().append(StringUtils.lowerCase(getSerializedTargetAccountingLine())).append("\n").append(StringUtils.lowerCase(getSerializedTargetAccountingLine()));
289:            // InputStream input = new ByteArrayInputStream(buffer.toString().getBytes());
290:            // List result = null;
291:            // List expected = null;
292:            // TransactionalDocument document = getDocument();
293:            // expected = getImportSourceAccountingLinesExpected(document);
294:            // result = getAccountingLineParser().importSourceAccountingLines(input, document);
295:            // assertTrue((result != null));
296:            // assertEquals(expected.toString(), result.toString());
297:            // }
298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.