Source Code Cross Referenced for SubAccountRuleTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » chart » 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.chart.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.chart.rules;
017:
018:        import static org.kuali.test.fixtures.UserNameFixture.KHUNTLEY;
019:        import static org.kuali.test.util.KualiTestAssertionUtils.assertGlobalErrorMapEmpty;
020:        import static org.kuali.test.util.KualiTestAssertionUtils.assertGlobalErrorMapSize;
021:
022:        import org.kuali.core.bo.user.AuthenticationUserId;
023:        import org.kuali.core.bo.user.UniversalUser;
024:        import org.kuali.core.document.MaintenanceDocument;
025:        import org.kuali.core.exceptions.UserNotFoundException;
026:        import org.kuali.core.service.UniversalUserService;
027:        import org.kuali.core.util.GlobalVariables;
028:        import org.kuali.kfs.KFSKeyConstants;
029:        import org.kuali.kfs.context.SpringContext;
030:        import org.kuali.module.chart.bo.SubAccount;
031:        import org.kuali.test.ConfigureContext;
032:        import org.kuali.test.fixtures.SubAccountFixture;
033:        import org.kuali.test.fixtures.UserNameFixture;
034:
035:        @ConfigureContext(session=KHUNTLEY)
036:        public class SubAccountRuleTest extends ChartRuleTestBase {
037:
038:            protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
039:                    .getLogger(SubAccountRuleTest.class);
040:
041:            private static final String GOOD_CHART = "UA";
042:            private static final String GOOD_ACCOUNT = "1912201";
043:            private static final String NEW_SUBACCOUNT_NUMBER = "12345";
044:            private static final String NEW_SUBACCOUNT_NAME = "A New SubAccount";
045:
046:            // CG authorized test users
047:            private static final UserNameFixture GOOD_CG_USERID = UserNameFixture.KCOPLEY;
048:            private static final UserNameFixture BAD_CG_USERID = UserNameFixture.JHAVENS;
049:
050:            SubAccount newSubAccount;
051:            SubAccount oldSubAccount;
052:            MaintenanceDocument maintDoc;
053:
054:            /**
055:             * This method creates a new SubAccount, and populates it with the data provided. No fields are required for this method, though
056:             * some may be for the rules. This method calls subAccount.refresh() before returning it, so all sub-objects should be
057:             * populated, if the keys match any records in the corresponding tables. This method does not populate anything in the contained
058:             * A21SubAccount, though it does create a new A21SubAccount. So the A21SubAccount instance will be valid (ie, non-null), but all
059:             * of its fields will be default or null.
060:             * 
061:             * @param chartOfAccountsCode
062:             * @param accountNumber
063:             * @param subAccountNumber
064:             * @param subAccountName
065:             * @param subAccountActiveIndicator
066:             * @param finReportChartCode
067:             * @param finReportOrgCode
068:             * @param finReportingCode
069:             * @return returns a SubAccount instance populated with the data provided
070:             */
071:            private SubAccount newSubAccount(String chartOfAccountsCode,
072:                    String accountNumber, String subAccountNumber,
073:                    String subAccountName, boolean subAccountActiveIndicator,
074:                    String finReportChartCode, String finReportOrgCode,
075:                    String finReportingCode) {
076:
077:                SubAccount subAccount = new SubAccount();
078:
079:                subAccount.setChartOfAccountsCode(chartOfAccountsCode);
080:                subAccount.setAccountNumber(accountNumber);
081:                subAccount.setSubAccountNumber(subAccountNumber);
082:                subAccount.setSubAccountName(subAccountName);
083:                subAccount
084:                        .setSubAccountActiveIndicator(subAccountActiveIndicator);
085:                subAccount.setFinancialReportChartCode(finReportChartCode);
086:                subAccount.setFinReportOrganizationCode(finReportOrgCode);
087:                subAccount.setFinancialReportingCode(finReportingCode);
088:                subAccount.refresh();
089:
090:                return subAccount;
091:            }
092:
093:            private UniversalUser createKualiUser(String userid) {
094:                UniversalUser user = new UniversalUser();
095:                try {
096:                    user = SpringContext.getBean(UniversalUserService.class)
097:                            .getUniversalUser(new AuthenticationUserId(userid));
098:                } catch (Exception e) {
099:                    e.printStackTrace();
100:                    return null;
101:                }
102:                return user;
103:            }
104:
105:            public void testCheckForPartiallyEnteredReportingFields_nullChartAndAccount() {
106:                SubAccountRule rule = new SubAccountRule();
107:
108:                // setup rule, document, and bo
109:                newSubAccount = newSubAccount(null, null,
110:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, null,
111:                        null, null);
112:                rule = (SubAccountRule) setupMaintDocRule(newSubAccount, rule
113:                        .getClass());
114:
115:                // confirm that there are no errors to begin with
116:                assertGlobalErrorMapEmpty();
117:
118:                // run the rule, should return true
119:                assertEquals(true, rule
120:                        .checkForPartiallyEnteredReportingFields());
121:                assertGlobalErrorMapEmpty();
122:
123:            }
124:
125:            public void testCheckForPartiallyEnteredReportingFields_goodChartNullAccount() {
126:                SubAccountRule rule = new SubAccountRule();
127:
128:                // setup rule, document, and bo
129:                newSubAccount = newSubAccount(GOOD_CHART, null,
130:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, null,
131:                        null, null);
132:                rule = (SubAccountRule) setupMaintDocRule(newSubAccount, rule
133:                        .getClass());
134:
135:                // confirm that there are no errors to begin with
136:                assertGlobalErrorMapEmpty();
137:
138:                // run the rule, should return true
139:                assertEquals(true, rule
140:                        .checkForPartiallyEnteredReportingFields());
141:                assertGlobalErrorMapEmpty();
142:
143:            }
144:
145:            public void testCheckForPartiallyEnteredReportingFields_nullChartGoodAccount() {
146:                SubAccountRule rule = new SubAccountRule();
147:
148:                // setup rule, document, and bo
149:                newSubAccount = newSubAccount(null, GOOD_ACCOUNT,
150:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, null,
151:                        null, null);
152:                rule = (SubAccountRule) setupMaintDocRule(newSubAccount, rule
153:                        .getClass());
154:
155:                // confirm that there are no errors to begin with
156:                assertGlobalErrorMapEmpty();
157:
158:                // run the rule, should return true
159:                assertEquals(true, rule
160:                        .checkForPartiallyEnteredReportingFields());
161:                assertGlobalErrorMapEmpty();
162:
163:            }
164:
165:            public void testCheckForPartiallyEnteredReportingFields_goodChartAndAccount() {
166:                SubAccountRule rule = new SubAccountRule();
167:
168:                // setup rule, document, and bo
169:                newSubAccount = newSubAccount(GOOD_CHART, GOOD_ACCOUNT,
170:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, null,
171:                        null, null);
172:                rule = (SubAccountRule) setupMaintDocRule(newSubAccount, rule
173:                        .getClass());
174:
175:                // confirm that there are no errors to begin with
176:                assertGlobalErrorMapEmpty();
177:
178:                // run the rule, should return true
179:                assertEquals(true, rule
180:                        .checkForPartiallyEnteredReportingFields());
181:                assertGlobalErrorMapEmpty();
182:
183:            }
184:
185:            private void proveNotAllFinReportCodesEntered(SubAccount subAccount) {
186:
187:                // setup the rule, and inject the subaccount
188:                SubAccountRule rule = new SubAccountRule();
189:                rule = (SubAccountRule) setupMaintDocRule(newSubAccount, rule
190:                        .getClass());
191:
192:                // confirm that there are no errors to begin with
193:                assertGlobalErrorMapEmpty();
194:
195:                // run the rule, should return true
196:                boolean result = rule.checkForPartiallyEnteredReportingFields();
197:                assertEquals(false, result);
198:                assertGlobalErrorMapSize(1);
199:                assertGlobalErrorExists(KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_RPTCODE_ALL_FIELDS_IF_ANY_FIELDS);
200:                GlobalVariables.getErrorMap().clear();
201:            }
202:
203:            public void testCheckForPartiallyEnteredReportingFields_notAllFinReportCodesEntered() {
204:
205:                // setup rule, document, and bo
206:                newSubAccount = newSubAccount(null, null,
207:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, "UA",
208:                        null, null);
209:                proveNotAllFinReportCodesEntered(newSubAccount);
210:
211:                // setup rule, document, and bo
212:                newSubAccount = newSubAccount(null, null,
213:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, null,
214:                        "KUL", null);
215:                proveNotAllFinReportCodesEntered(newSubAccount);
216:
217:                // setup rule, document, and bo
218:                newSubAccount = newSubAccount(null, null,
219:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, null,
220:                        null, "KUL");
221:                proveNotAllFinReportCodesEntered(newSubAccount);
222:
223:                // setup rule, document, and bo
224:                newSubAccount = newSubAccount(null, null,
225:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, "UA",
226:                        "KUL", null);
227:                proveNotAllFinReportCodesEntered(newSubAccount);
228:
229:                // setup rule, document, and bo
230:                newSubAccount = newSubAccount(null, null,
231:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, "UA",
232:                        null, "KUL");
233:                proveNotAllFinReportCodesEntered(newSubAccount);
234:
235:                // setup rule, document, and bo
236:                newSubAccount = newSubAccount(null, null,
237:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, null,
238:                        "KUL", "KUL");
239:                proveNotAllFinReportCodesEntered(newSubAccount);
240:
241:            }
242:
243:            /**
244:             * This method simulates a user that has permission to deal with CG accounts
245:             */
246:            public void testIsCgAuthorized_goodUser()
247:                    throws UserNotFoundException {
248:                SubAccountRule rule = new SubAccountRule();
249:                UniversalUser user = GOOD_CG_USERID.getUniversalUser();
250:                // setup rule, document, and bo
251:                newSubAccount = newSubAccount(GOOD_CHART, GOOD_ACCOUNT,
252:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, null,
253:                        null, null);
254:                rule = (SubAccountRule) setupMaintDocRule(newSubAccount, rule
255:                        .getClass());
256:
257:                // confirm that there are no errors to begin with
258:                assertGlobalErrorMapEmpty();
259:                assertEquals(true, rule.isCgAuthorized(user));
260:
261:            }
262:
263:            /**
264:             * This method simulates a user that does not have permission to deal with CG accounts
265:             */
266:            public void testIsCgAuthorized_badUser()
267:                    throws UserNotFoundException {
268:                SubAccountRule rule = new SubAccountRule();
269:                UniversalUser user = BAD_CG_USERID.getUniversalUser();
270:                // setup rule, document, and bo
271:                newSubAccount = newSubAccount(GOOD_CHART, GOOD_ACCOUNT,
272:                        NEW_SUBACCOUNT_NUMBER, NEW_SUBACCOUNT_NAME, true, null,
273:                        null, null);
274:                rule = (SubAccountRule) setupMaintDocRule(newSubAccount, rule
275:                        .getClass());
276:
277:                // confirm that there are no errors to begin with
278:                assertGlobalErrorMapEmpty();
279:                assertEquals(false, rule.isCgAuthorized(user));
280:            }
281:
282:            public void testCheckCgRules_badFundGroup() {
283:                SubAccountRule rule = new SubAccountRule();
284:                // setup rule, document, and bo
285:                newSubAccount = SubAccountFixture.SUB_ACCOUNT_WITH_BAD_CG_FUND_GROUP
286:                        .createSubAccount();
287:                newSubAccount.refresh();
288:                rule = (SubAccountRule) setupMaintDocRule(newSubAccount, rule
289:                        .getClass());
290:
291:                // confirm that there are no errors to begin with
292:                assertGlobalErrorMapEmpty();
293:                assertEquals(true, rule.checkCgRules(maintDoc));
294:            }
295:
296:            public void testCheckCgRules_badA21SubAccountAccountType()
297:                    throws Exception {
298:                SubAccountRule rule = new SubAccountRule();
299:                // setup rule, document, and bo
300:                newSubAccount = SubAccountFixture.A21_SUB_ACCOUNT_WITH_BAD_CG_ACCOUNT_TYPE
301:                        .createSubAccount();
302:                newSubAccount.getA21SubAccount().refresh();
303:                String fieldName = "a21SubAccount.subAccountTypeCode";
304:                rule = (SubAccountRule) setupMaintDocRule(newSubAccount, rule
305:                        .getClass());
306:                rule.setCgAuthorized(true);
307:
308:                // confirm that there are no errors to begin with
309:                assertGlobalErrorMapEmpty();
310:                assertEquals(false, rule.checkCgRules(maintDoc));
311:                assertFieldErrorExists(
312:                        fieldName,
313:                        KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_INVALI_SUBACCOUNT_TYPE_CODES);
314:                assertGlobalErrorMapSize(1);
315:            }
316:
317:            /**
318:             * Incomplete TODO: Write tests for this method to accompany the testCheckCgRules
319:             */
320:            /*
321:             * public void testCheckCgCostSharingRules() { }
322:             */
323:
324:            /**
325:             * Incomplete TODO: Write tests for this method to accompany the testCheckCgRules
326:             */
327:            /*
328:             * public void testCheckCgIcrRules() { }
329:             */
330:
331:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.