Source Code Cross Referenced for AccountingLineRuleUtilTest.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.fixtures.AccountFixture.ACCOUNT_NON_PRESENCE_ACCOUNT;
019:        import static org.kuali.test.fixtures.AccountFixture.ACCOUNT_PRESENCE_ACCOUNT_BUT_CLOSED;
020:        import static org.kuali.test.fixtures.AccountFixture.ACCOUNT_PRESENCE_ACCOUNT_WITH_EXPIRED;
021:        import static org.kuali.test.fixtures.AccountFixture.ACTIVE_ACCOUNT;
022:        import static org.kuali.test.fixtures.AccountFixture.CLOSED_ACCOUNT;
023:        import static org.kuali.test.fixtures.AccountFixture.EXPIRIED_ACCOUNT;
024:        import static org.kuali.test.fixtures.AccountFixture.EXPIRIED_ACCOUNT_EXPIRIED_AND_CLOSED_CONTINUATION;
025:        import static org.kuali.test.fixtures.AccountFixture.EXPIRIED_ACCOUNT_EXPIRIED_AND_OPEN_CONTINUATION;
026:        import static org.kuali.test.fixtures.AccountFixture.EXPIRIED_ACCOUNT_NO_CONTINUATION;
027:        import static org.kuali.test.fixtures.ObjectCodeFixture.OBJECT_CODE_BUDGETED_OBJECT_CODE;
028:        import static org.kuali.test.fixtures.ObjectCodeFixture.OBJECT_CODE_NON_BUDGET_OBJECT_CODE;
029:        import static org.kuali.test.util.KualiTestAssertionUtils.assertGlobalErrorMapContains;
030:        import static org.kuali.test.util.KualiTestAssertionUtils.assertGlobalErrorMapEmpty;
031:
032:        import org.kuali.core.service.BusinessObjectService;
033:        import org.kuali.core.service.DataDictionaryService;
034:        import org.kuali.kfs.KFSConstants;
035:        import org.kuali.kfs.KFSKeyConstants;
036:        import org.kuali.kfs.bo.AccountingLine;
037:        import org.kuali.kfs.bo.AccountingLineOverride;
038:        import org.kuali.kfs.bo.SourceAccountingLine;
039:        import org.kuali.kfs.context.KualiTestBase;
040:        import org.kuali.kfs.context.SpringContext;
041:        import org.kuali.kfs.rules.AccountingLineRuleUtil;
042:        import org.kuali.module.chart.bo.Account;
043:        import org.kuali.module.chart.bo.ObjectCode;
044:        import org.kuali.test.ConfigureContext;
045:
046:        /**
047:         * This class tests some methods of AccountingLineRuleUtil.
048:         */
049:        @ConfigureContext
050:        public class AccountingLineRuleUtilTest extends KualiTestBase {
051:
052:            public void testLabelsAreInDataDictionary() {
053:                assertNotNull(AccountingLineRuleUtil.getChartLabel());
054:                assertNotNull(AccountingLineRuleUtil.getAccountLabel());
055:                assertNotNull(AccountingLineRuleUtil.getSubAccountLabel());
056:                assertNotNull(AccountingLineRuleUtil.getObjectCodeLabel());
057:                assertNotNull(AccountingLineRuleUtil.getSubObjectCodeLabel());
058:                assertNotNull(AccountingLineRuleUtil.getProjectCodeLabel());
059:                assertNotNull(AccountingLineRuleUtil.getObjectTypeCodeLabel());
060:                assertNotNull(AccountingLineRuleUtil
061:                        .getObjectSubTypeCodeLabel());
062:                assertNotNull(AccountingLineRuleUtil.getOrganizationCodeLabel());
063:                assertNotNull(AccountingLineRuleUtil.getFundGroupCodeLabel());
064:                assertNotNull(AccountingLineRuleUtil.getSubFundGroupCodeLabel());
065:            }
066:
067:            public void testIsValidAccount_valid() {
068:                testIsValidAccount(ACTIVE_ACCOUNT.createAccount(), null);
069:            }
070:
071:            public void testIsValidAccount_null() {
072:                testIsValidAccount(null, KFSKeyConstants.ERROR_EXISTENCE);
073:            }
074:
075:            public void testIsValidAccount_closed() {
076:                testIsValidAccount(CLOSED_ACCOUNT.createAccount(),
077:                        KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_CLOSED);
078:            }
079:
080:            private void testIsValidAccount(Account account,
081:                    String expectedErrorKey) {
082:                assertGlobalErrorMapEmpty();
083:                boolean actual = AccountingLineRuleUtil.isValidAccount(account,
084:                        SpringContext.getBean(DataDictionaryService.class)
085:                                .getDataDictionary());
086:                assertEquals("isValidAccount result", expectedErrorKey == null,
087:                        actual);
088:                if (expectedErrorKey == null) {
089:                    assertGlobalErrorMapEmpty();
090:                } else {
091:                    assertGlobalErrorMapContains(
092:                            KFSConstants.ACCOUNT_NUMBER_PROPERTY_NAME,
093:                            expectedErrorKey);
094:                }
095:            }
096:
097:            public void testHasRequiredOverrides_valid() {
098:                testHasRequiredOverrides(ACTIVE_ACCOUNT.createAccount(),
099:                        AccountingLineOverride.CODE.NONE, null, null);
100:            }
101:
102:            public void testHasRequiredOverrides_null() {
103:                testHasRequiredOverrides(null,
104:                        AccountingLineOverride.CODE.NONE, null, null);
105:            }
106:
107:            public void testHasRequiredOverrides_closed() {
108:                testHasRequiredOverrides(CLOSED_ACCOUNT.createAccount(),
109:                        AccountingLineOverride.CODE.NONE, null, null);
110:            }
111:
112:            public void testHasRequiredOverrides_expired() {
113:                testHasRequiredOverrides(EXPIRIED_ACCOUNT.createAccount(),
114:                        AccountingLineOverride.CODE.NONE,
115:                        KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_EXPIRED,
116:                        new String[] { EXPIRIED_ACCOUNT.accountNumber,
117:                                EXPIRIED_ACCOUNT.chartOfAccountsCode,
118:                                EXPIRIED_ACCOUNT.continuationAccountNumber });
119:            }
120:
121:            public void testHasRequiredOverrides_expiredContinuationsClosedAndExpired() {
122:                testHasRequiredOverrides(
123:                        EXPIRIED_ACCOUNT_EXPIRIED_AND_CLOSED_CONTINUATION
124:                                .createAccount(),
125:                        AccountingLineOverride.CODE.NONE,
126:                        KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_EXPIRED,
127:                        new String[] {
128:                                EXPIRIED_ACCOUNT_EXPIRIED_AND_CLOSED_CONTINUATION.accountNumber,
129:                                EXPIRIED_ACCOUNT_EXPIRIED_AND_CLOSED_CONTINUATION.continuationFinChrtOfAcctCd,
130:                                EXPIRIED_ACCOUNT.continuationAccountNumber });
131:            }
132:
133:            public void testHasRequiredOverrides_expiredContinuationExpired() {
134:                testHasRequiredOverrides(
135:                        EXPIRIED_ACCOUNT_EXPIRIED_AND_OPEN_CONTINUATION
136:                                .createAccount(),
137:                        AccountingLineOverride.CODE.NONE,
138:                        KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_EXPIRED,
139:                        new String[] {
140:                                EXPIRIED_ACCOUNT_EXPIRIED_AND_OPEN_CONTINUATION.accountNumber,
141:                                EXPIRIED_ACCOUNT_EXPIRIED_AND_OPEN_CONTINUATION.continuationFinChrtOfAcctCd,
142:                                EXPIRIED_ACCOUNT.continuationAccountNumber });
143:            }
144:
145:            public void testHasRequiredOverrides_expiredNoContinuation() {
146:                testHasRequiredOverrides(
147:                        EXPIRIED_ACCOUNT_NO_CONTINUATION.createAccount(),
148:                        AccountingLineOverride.CODE.NONE,
149:                        KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_EXPIRED_NO_CONTINUATION,
150:                        null);
151:            }
152:
153:            public void testHasRequiredOverrides_expiredButOverridden() {
154:                testHasRequiredOverrides(EXPIRIED_ACCOUNT.createAccount(),
155:                        AccountingLineOverride.CODE.EXPIRED_ACCOUNT, null, null);
156:            }
157:
158:            public void testHasRequiredOverrides_expiredNoContinuationButOverridden() {
159:                testHasRequiredOverrides(EXPIRIED_ACCOUNT_NO_CONTINUATION
160:                        .createAccount(),
161:                        AccountingLineOverride.CODE.EXPIRED_ACCOUNT, null, null);
162:            }
163:
164:            public void testHasRequiredOverrides_expiredButMultipleOverridden() {
165:                testHasRequiredOverrides(
166:                        EXPIRIED_ACCOUNT.createAccount(),
167:                        AccountingLineOverride.CODE.EXPIRED_ACCOUNT_AND_NON_FRINGE_ACCOUNT_USED,
168:                        null, null);
169:            }
170:
171:            // public void testHasRequiredOverrides_AccountPresenceBudgetedObject() {
172:            // testHasRequiredOverrides(ACCOUNT_PRESENCE_ACCOUNT.createAccount(businessObjectService), getBudgetedObjectCode(),
173:            // AccountingLineOverride.CODE.NONE, null);
174:            // }
175:            //
176:            // public void testHasRequiredOverrides_AccountPresenceNonBudgetObject() {
177:            // testHasRequiredOverrides(ACCOUNT_PRESENCE_ACCOUNT.createAccount(businessObjectService), getNonBudgetedObjectCode(),
178:            // AccountingLineOverride.CODE.NON_BUDGETED_OBJECT,
179:            // KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_PRESENCE_NON_BUDGETED_OBJECT_CODE);
180:            // }
181:
182:            public void testHasRequiredOverrides_NoAccountPresenceBudgetedObject() {
183:                testHasRequiredOverrides(ACCOUNT_NON_PRESENCE_ACCOUNT
184:                        .createAccount(SpringContext
185:                                .getBean(BusinessObjectService.class)),
186:                        OBJECT_CODE_BUDGETED_OBJECT_CODE
187:                                .createObjectCode(SpringContext
188:                                        .getBean(BusinessObjectService.class)),
189:                        AccountingLineOverride.CODE.NONE, null);
190:            }
191:
192:            public void testHasRequiredOverrides_NoAccountPresenceNonBudgetedObject() {
193:                testHasRequiredOverrides(ACCOUNT_NON_PRESENCE_ACCOUNT
194:                        .createAccount(SpringContext
195:                                .getBean(BusinessObjectService.class)),
196:                        OBJECT_CODE_NON_BUDGET_OBJECT_CODE
197:                                .createObjectCode(SpringContext
198:                                        .getBean(BusinessObjectService.class)),
199:                        AccountingLineOverride.CODE.NONE, null);
200:            }
201:
202:            public void testHasRequiredOverrides_NoAccountPresenceNonBudgetedObjectAccountExpired() {
203:                testHasRequiredOverrides(
204:                        ACCOUNT_PRESENCE_ACCOUNT_WITH_EXPIRED
205:                                .createAccount(SpringContext
206:                                        .getBean(BusinessObjectService.class)),
207:                        OBJECT_CODE_NON_BUDGET_OBJECT_CODE
208:                                .createObjectCode(SpringContext
209:                                        .getBean(BusinessObjectService.class)),
210:                        AccountingLineOverride.CODE.EXPIRED_ACCOUNT_AND_NON_BUDGETED_OBJECT,
211:                        null);
212:            }
213:
214:            public void testHasRequiredOverrides_closedAccountNonBudgetedObject() {
215:                // This account would require a non-budgeted override if it were not closed. But, the closed validation takes precedence.
216:                testHasRequiredOverrides(ACCOUNT_PRESENCE_ACCOUNT_BUT_CLOSED
217:                        .createAccount(SpringContext
218:                                .getBean(BusinessObjectService.class)),
219:                        OBJECT_CODE_NON_BUDGET_OBJECT_CODE
220:                                .createObjectCode(SpringContext
221:                                        .getBean(BusinessObjectService.class)),
222:                        AccountingLineOverride.CODE.NONE, null);
223:            }
224:
225:            @SuppressWarnings("deprecation")
226:            private void testHasRequiredOverrides(Account account,
227:                    String overrideCode, String expectedErrorKey,
228:                    String[] expectedErrorParameters) {
229:                AccountingLine line = new SourceAccountingLine();
230:                line.setAccount(account);
231:
232:                assertGlobalErrorMapEmpty();
233:                boolean actual = AccountingLineRuleUtil.hasRequiredOverrides(
234:                        line, overrideCode);
235:                assertEquals("hasRequiredOverrides result",
236:                        expectedErrorKey == null, actual);
237:                if (expectedErrorKey == null) {
238:                    assertGlobalErrorMapEmpty();
239:                } else {
240:                    assertGlobalErrorMapContains(
241:                            KFSConstants.ACCOUNT_NUMBER_PROPERTY_NAME,
242:                            expectedErrorKey, expectedErrorParameters);
243:                }
244:            }
245:
246:            @SuppressWarnings("deprecation")
247:            private void testHasRequiredOverrides(Account account,
248:                    ObjectCode objectCode, String overrideCode,
249:                    String expectedErrorKey) {
250:                AccountingLine line = new SourceAccountingLine();
251:                line.setAccount(account);
252:                line.setObjectCode(objectCode);
253:
254:                assertGlobalErrorMapEmpty();
255:                boolean actual = AccountingLineRuleUtil.hasRequiredOverrides(
256:                        line, overrideCode);
257:                assertEquals("hasRequiredOverrides result",
258:                        expectedErrorKey == null, actual);
259:                if (expectedErrorKey == null) {
260:                    assertGlobalErrorMapEmpty();
261:                } else {
262:                    assertGlobalErrorMapContains(
263:                            KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME,
264:                            expectedErrorKey);
265:                }
266:            }
267:
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.