Source Code Cross Referenced for TransactionalDocumentRuleUtilTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » rules » 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.rules 
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.rules;
017:
018:        import static org.kuali.test.util.KualiTestAssertionUtils.assertGlobalErrorMapEmpty;
019:
020:        import org.kuali.core.service.DateTimeService;
021:        import org.kuali.kfs.KFSConstants;
022:        import org.kuali.kfs.KFSPropertyConstants;
023:        import org.kuali.kfs.context.KualiTestBase;
024:        import org.kuali.kfs.context.SpringContext;
025:        import org.kuali.kfs.rules.AccountingDocumentRuleUtil;
026:        import org.kuali.module.chart.bo.AccountingPeriod;
027:        import org.kuali.module.chart.bo.codes.BalanceTyp;
028:        import org.kuali.module.chart.service.AccountingPeriodService;
029:        import org.kuali.module.chart.service.BalanceTypService;
030:        import org.kuali.module.financial.document.JournalVoucherDocument;
031:        import org.kuali.test.ConfigureContext;
032:
033:        /**
034:         * Class for unit testing the functionality of <code>{@link TransactionalDocumentRuleUtil}</code>
035:         */
036:        @ConfigureContext
037:        public class TransactionalDocumentRuleUtilTest extends KualiTestBase {
038:
039:            private static final String DOES_NOT_MATTER = "doesNotMatter";
040:
041:            private static long ONE_DAY_MILLIS = 24 * 60 * 60 * 1000L;
042:
043:            private final String ANNUAL_BALANCE_PERIOD_CODE = "AB";
044:            private final Integer CURRENT_FISCAL_YEAR = new Integer("2004");
045:
046:            // /////////////////////////////////////////////////////////////////////////
047:            // Fixture Methods Start Here //
048:            // /////////////////////////////////////////////////////////////////////////
049:            /**
050:             * Accessor method to </code>errorPropertyName</code>
051:             * 
052:             * @return String
053:             */
054:            protected String getErrorPropertyName() {
055:                return KFSConstants.GLOBAL_ERRORS;
056:            }
057:
058:            /**
059:             * Fixture accessor method to get <code>{@link String}</code> serialization instance of an active balance type.
060:             * 
061:             * @return String
062:             */
063:            protected String getActiveBalanceType() {
064:                return KFSConstants.BALANCE_TYPE_ACTUAL;
065:            }
066:
067:            /**
068:             * Fixture accessor method to get <code>{@link String}</code> serialization instance of an inactive balance type.
069:             * 
070:             * @return String
071:             */
072:            protected String getInactiveBalanceType() {
073:                return KFSConstants.BALANCE_TYPE_ACTUAL;
074:            }
075:
076:            /**
077:             * Fixture accessor method for the Annual Balance <code>{@link AccountingPeriod}</code>
078:             * 
079:             * @return AccountingPeriod
080:             */
081:            public AccountingPeriod getAnnualBalanceAccountingPeriod() {
082:                return SpringContext.getBean(AccountingPeriodService.class)
083:                        .getByPeriod(ANNUAL_BALANCE_PERIOD_CODE,
084:                                CURRENT_FISCAL_YEAR);
085:            }
086:
087:            /**
088:             * Fixture accessor method for a closed <code>{@link AccountingPeriod}</code> instance.
089:             * 
090:             * @return AccountingPeriod
091:             */
092:            protected AccountingPeriod getClosedAccountingPeriod() {
093:                return null;
094:            }
095:
096:            /**
097:             * Fixture accessor method for getting a <code>{@link java.sql.Date}</code> instance that is in the past.
098:             * 
099:             * @return Timestamp
100:             */
101:            private java.sql.Date getSqlDateYesterday() {
102:                return new java.sql.Date(SpringContext.getBean(
103:                        DateTimeService.class).getCurrentDate().getTime()
104:                        - ONE_DAY_MILLIS);
105:            }
106:
107:            /**
108:             * Fixture accessor method for getting a <code>{@link java.sql.Date}</code> instance that is in the future.
109:             */
110:            private java.sql.Date getSqlDateTomorrow() {
111:                return new java.sql.Date(SpringContext.getBean(
112:                        DateTimeService.class).getCurrentDate().getTime()
113:                        + ONE_DAY_MILLIS);
114:            }
115:
116:            /**
117:             * @return today's java.sql.Date
118:             */
119:            private java.sql.Date getSqlDateToday() {
120:                return new java.sql.Date(SpringContext.getBean(
121:                        DateTimeService.class).getCurrentDate().getTime());
122:            }
123:
124:            // /////////////////////////////////////////////////////////////////////////
125:            // Fixture Methods End Here //
126:            // /////////////////////////////////////////////////////////////////////////
127:
128:            // /////////////////////////////////////////////////////////////////////////
129:            // Test Methods Start Here //
130:            // /////////////////////////////////////////////////////////////////////////
131:            /**
132:             * test the <code>isValidBalanceType()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
133:             * 
134:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidBalanceType
135:             */
136:            public void testIsValidBalanceType_Active() {
137:                testIsValidBalanceType(getActiveBalanceType(), true);
138:            }
139:
140:            /**
141:             * test the <code>isValidBalanceType()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
142:             * 
143:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidBalanceType
144:             */
145:            public void testIsValidBalanceType_Inactive() {
146:                testIsValidBalanceType(getInactiveBalanceType(), true);
147:            }
148:
149:            /**
150:             * test the <code>isValidBalanceType()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
151:             * 
152:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidBalanceType
153:             */
154:            public void testIsValidBalanceType_Null() {
155:                testIsValidBalanceType(null, false);
156:            }
157:
158:            /**
159:             * test the <code>isValidBalanceType()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
160:             * 
161:             * @param btStr
162:             * @param expected
163:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidBalanceType
164:             */
165:            protected void testIsValidBalanceType(String btStr, boolean expected) {
166:                BalanceTyp balanceType = null;
167:
168:                if (btStr != null) {
169:                    balanceType = SpringContext
170:                            .getBean(BalanceTypService.class)
171:                            .getBalanceTypByCode(btStr);
172:                }
173:                assertGlobalErrorMapEmpty();
174:                boolean result = AccountingDocumentRuleUtil.isValidBalanceType(
175:                        balanceType, "code");
176:                if (expected) {
177:                    assertGlobalErrorMapEmpty();
178:                }
179:                assertEquals("result", expected, result);
180:            }
181:
182:            /**
183:             * test the <code>isValidOpenAccountingPeriod()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
184:             * 
185:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidOpenAccountingPeriod
186:             */
187:            // @RelatesTo(JiraIssue.KULRNE4926)
188:            public void testIsValidOpenAccountingPeriod_Open() {
189:                testIsValidOpenAccountingPeriod(
190:                        getAnnualBalanceAccountingPeriod(), true);
191:            }
192:
193:            /**
194:             * test the <code>isValidOpenAccountingPeriod()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
195:             * 
196:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidOpenAccountingPeriod
197:             */
198:            public void pendingTestIsValidOpenAccountingPeriod_Closed() {
199:                testIsValidOpenAccountingPeriod(getClosedAccountingPeriod(),
200:                        false);
201:            }
202:
203:            /**
204:             * test the <code>isValidOpenAccountingPeriod()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
205:             * 
206:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidOpenAccountingPeriod
207:             */
208:            // @RelatesTo(JiraIssue.KULRNE4926)
209:            public void testIsValidOpenAccountingPeriod_Null() {
210:                testIsValidOpenAccountingPeriod(null, false);
211:            }
212:
213:            /**
214:             * test the <code>isValidOpenAccountingPeriod()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
215:             * 
216:             * @param period
217:             * @param expected
218:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidOpenAccountingPeriod
219:             */
220:            protected void testIsValidOpenAccountingPeriod(
221:                    AccountingPeriod period, boolean expected) {
222:                assertGlobalErrorMapEmpty();
223:                boolean result = AccountingDocumentRuleUtil
224:                        .isValidOpenAccountingPeriod(period,
225:                                JournalVoucherDocument.class,
226:                                KFSPropertyConstants.ACCOUNTING_PERIOD,
227:                                DOES_NOT_MATTER);
228:                if (expected) {
229:                    assertGlobalErrorMapEmpty();
230:                }
231:                assertEquals("result", expected, result);
232:            }
233:
234:            /**
235:             * test the <code>isValidReversalDate()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
236:             * 
237:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidReversalDate
238:             */
239:            public void testIsValidReversalDate_Null() {
240:                testIsValidReversalDate(null, true);
241:            }
242:
243:            /**
244:             * test the <code>isValidReversalDate()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
245:             * 
246:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidReversalDate
247:             */
248:            public void testIsValidReversalDate_Past() {
249:                testIsValidReversalDate(getSqlDateYesterday(), false);
250:            }
251:
252:            /**
253:             * test the <code>isValidReversalDate()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
254:             * 
255:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidReversalDate
256:             */
257:            public void testIsValidReversalDate_Future() {
258:                testIsValidReversalDate(getSqlDateTomorrow(), true);
259:            }
260:
261:            public void testIsValidReversalDate_Today() {
262:                testIsValidReversalDate(getSqlDateToday(), true);
263:            }
264:
265:            /**
266:             * test the <code>isValidReversalDate()</code> method of <code>{@link TransactionalDocumentRuleUtil}</code>
267:             * 
268:             * @param reversalDate
269:             * @param expected
270:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleUtil#isValidReversalDate
271:             */
272:            protected void testIsValidReversalDate(java.sql.Date reversalDate,
273:                    boolean expected) {
274:                assertGlobalErrorMapEmpty();
275:                boolean result = AccountingDocumentRuleUtil
276:                        .isValidReversalDate(reversalDate,
277:                                getErrorPropertyName());
278:                if (expected) {
279:                    assertGlobalErrorMapEmpty();
280:                }
281:                assertEquals("result", expected, result);
282:            }
283:
284:            // /////////////////////////////////////////////////////////////////////////
285:            // Test Methods End Here //
286:            // /////////////////////////////////////////////////////////////////////////
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.