Source Code Cross Referenced for OrgRuleTest.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:
021:        import java.util.HashMap;
022:        import java.util.Map;
023:
024:        import org.kuali.core.document.MaintenanceDocument;
025:        import org.kuali.core.service.BusinessObjectService;
026:        import org.kuali.kfs.KFSConstants;
027:        import org.kuali.kfs.context.SpringContext;
028:        import org.kuali.module.chart.bo.Org;
029:        import org.kuali.test.ConfigureContext;
030:
031:        @ConfigureContext(session=KHUNTLEY)
032:        public class OrgRuleTest extends ChartRuleTestBase {
033:
034:            private static final String GOOD_CHART = "UA";
035:            private static final String BAD_CHART = "ZZ";
036:
037:            private static class OrgKeys {
038:                private String chartOfAccountsCode;
039:                private String organizationCode;
040:                private String organizationManager;
041:
042:                private OrgKeys(String chartOfAccountsCode,
043:                        String organizationCode, String organizationManager) {
044:                    this .chartOfAccountsCode = chartOfAccountsCode;
045:                    this .organizationCode = organizationCode;
046:                    this .organizationManager = organizationManager;
047:                }
048:
049:                static OrgKeys getGoodTopLevelOrgKeys() {
050:                    return new OrgKeys(TopLevelOrg.CHART_OF_ACCOUNTS_CODE,
051:                            TopLevelOrg.ORGANIZATION_CODE,
052:                            TopLevelOrg.ORGANIZATION_MANAGER);
053:                }
054:
055:                static OrgKeys getBadTopLevelOrgKeys() {
056:                    return new OrgKeys(CampusOrg.CHART_OF_ACCOUNTS_CODE,
057:                            CampusOrg.ORGANIZATION_CODE,
058:                            CampusOrg.ORGANIZATION_MANAGER);
059:                }
060:
061:                static OrgKeys getCampusOrgKeys() {
062:                    return new OrgKeys(CampusOrg.CHART_OF_ACCOUNTS_CODE,
063:                            CampusOrg.ORGANIZATION_CODE,
064:                            CampusOrg.ORGANIZATION_MANAGER);
065:                }
066:
067:                static OrgKeys getDepartmentOrgKeys() {
068:                    return new OrgKeys(DepartmentOrg.CHART_OF_ACCOUNTS_CODE,
069:                            DepartmentOrg.ORGANIZATION_CODE,
070:                            DepartmentOrg.ORGANIZATION_MANAGER);
071:                }
072:
073:                private class TopLevelOrg {
074:                    private static final String CHART_OF_ACCOUNTS_CODE = "IU";
075:                    private static final String ORGANIZATION_CODE = "UNIV";
076:                    private static final String ORGANIZATION_MANAGER = "CAMCSWEE";
077:                }
078:
079:                private class CampusOrg {
080:                    private static final String CHART_OF_ACCOUNTS_CODE = "FW";
081:                    private static final String ORGANIZATION_CODE = "FW";
082:                    private static final String ORGANIZATION_MANAGER = "MFLANDER";
083:                }
084:
085:                private class DepartmentOrg {
086:                    private static final String CHART_OF_ACCOUNTS_CODE = "FW";
087:                    private static final String ORGANIZATION_CODE = "ANTH";
088:                    private static final String ORGANIZATION_MANAGER = "HOATES";
089:                }
090:            }
091:
092:            private OrgRule rule;
093:            private Org org;
094:            private MaintenanceDocument maintDoc;
095:
096:            public void testDefaultExistenceChecks_chartOfAccounts_good() {
097:                org = (Org) SpringContext.getBean(BusinessObjectService.class)
098:                        .findByPrimaryKey(
099:                                Org.class,
100:                                getPrimaryKeysForTopLevelOrg(OrgKeys
101:                                        .getGoodTopLevelOrgKeys()));
102:                maintDoc = this .newMaintDoc(org);
103:                testDefaultExistenceCheck(org, "organizationCode", false);
104:                assertGlobalErrorMapEmpty();
105:            }
106:
107:            /**
108:             * This tests makes certain that only one top level heirarchy is allowed.
109:             */
110:            public void testCheckSimpleRules_topLevelHeirarchy_noMoreThanOne() {
111:                Org oldBO = (Org) SpringContext.getBean(
112:                        BusinessObjectService.class).findByPrimaryKey(
113:                        Org.class,
114:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
115:                                .getGoodTopLevelOrgKeys()));
116:                Org newBO = (Org) SpringContext.getBean(
117:                        BusinessObjectService.class).findByPrimaryKey(
118:                        Org.class,
119:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
120:                                .getBadTopLevelOrgKeys()));
121:                maintDoc = this .newMaintDoc(oldBO, newBO);
122:                maintDoc.getNewMaintainableObject().setMaintenanceAction(
123:                        KFSConstants.MAINTENANCE_EDIT_ACTION); // simulate editing
124:                newBO
125:                        .setReportsToChartOfAccountsCode(OrgKeys.CampusOrg.CHART_OF_ACCOUNTS_CODE); // simulate trying to create a new top
126:                // level org
127:                newBO
128:                        .setReportsToOrganizationCode(OrgKeys.CampusOrg.ORGANIZATION_CODE);
129:                rule = (OrgRule) this 
130:                        .setupMaintDocRule(maintDoc, OrgRule.class);
131:                assertFalse(rule.checkSimpleRules(maintDoc)); // we may not add more than one top level org
132:            }
133:
134:            /**
135:             * This test makes certain that a top level heirarchy can be edited in a maintenance doc.
136:             */
137:            public void testCheckSimpleRules_topLevelHeirarchy_mayEdit() {
138:                rule = new OrgRule();
139:                Org oldBO = (Org) SpringContext.getBean(
140:                        BusinessObjectService.class).findByPrimaryKey(
141:                        Org.class,
142:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
143:                                .getGoodTopLevelOrgKeys()));
144:                Org newBO = (Org) SpringContext.getBean(
145:                        BusinessObjectService.class).findByPrimaryKey(
146:                        Org.class,
147:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
148:                                .getGoodTopLevelOrgKeys()));
149:                newBO
150:                        .setReportsToChartOfAccountsCode(OrgKeys.TopLevelOrg.CHART_OF_ACCOUNTS_CODE); // simulate editing top level org
151:                newBO
152:                        .setReportsToOrganizationCode(OrgKeys.TopLevelOrg.ORGANIZATION_CODE);
153:                maintDoc = this .newMaintDoc(oldBO, newBO);
154:                maintDoc.getNewMaintainableObject().setMaintenanceAction(
155:                        KFSConstants.MAINTENANCE_EDIT_ACTION); // simulate editing
156:                rule = (OrgRule) this 
157:                        .setupMaintDocRule(maintDoc, OrgRule.class);
158:                assertTrue(rule.checkSimpleRules(maintDoc)); // it is okay to edit the top level org
159:            }
160:
161:            /**
162:             * This method assures that on edit, a university level org does not need a default account number.
163:             */
164:            public void testCheckDefaultAccountNumber_canEditUniversity() {
165:                Org oldBO = (Org) SpringContext.getBean(
166:                        BusinessObjectService.class).findByPrimaryKey(
167:                        Org.class,
168:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
169:                                .getGoodTopLevelOrgKeys()));
170:                Org newBO = (Org) SpringContext.getBean(
171:                        BusinessObjectService.class).findByPrimaryKey(
172:                        Org.class,
173:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
174:                                .getGoodTopLevelOrgKeys()));
175:                newBO.setOrganizationDefaultAccountNumber(null); // simulate no organization default account number
176:                maintDoc = this .newMaintDoc(oldBO, newBO);
177:                maintDoc.getNewMaintainableObject().setMaintenanceAction(
178:                        KFSConstants.MAINTENANCE_EDIT_ACTION); // simulate editing
179:                rule = (OrgRule) this 
180:                        .setupMaintDocRule(maintDoc, OrgRule.class);
181:                assertTrue(rule.checkDefaultAccountNumber(maintDoc)); // it is okay for a university to have no default account number
182:            }
183:
184:            /**
185:             * This method assures that on edit, a campus level org does not need a default account number.
186:             */
187:            public void testCheckDefaultAccountNumber_canEditCampus() {
188:                Org oldBO = (Org) SpringContext.getBean(
189:                        BusinessObjectService.class).findByPrimaryKey(
190:                        Org.class,
191:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
192:                                .getCampusOrgKeys()));
193:                Org newBO = (Org) SpringContext.getBean(
194:                        BusinessObjectService.class).findByPrimaryKey(
195:                        Org.class,
196:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
197:                                .getCampusOrgKeys()));
198:                newBO.setOrganizationDefaultAccountNumber(null); // simulate no organization default account number
199:                maintDoc = this .newMaintDoc(oldBO, newBO);
200:                maintDoc.getNewMaintainableObject().setMaintenanceAction(
201:                        KFSConstants.MAINTENANCE_EDIT_ACTION); // simulate editing
202:                rule = (OrgRule) this 
203:                        .setupMaintDocRule(maintDoc, OrgRule.class);
204:                assertTrue(rule.checkDefaultAccountNumber(maintDoc)); // it is okay for a campus to have no default account number
205:            }
206:
207:            /**
208:             * This method assures that on edit, a non-university/non-campus *does* need a default account number.
209:             */
210:            public void testCheckDefaultAccountNumber_cannotEditDepartment() {
211:                Org oldBO = (Org) SpringContext.getBean(
212:                        BusinessObjectService.class).findByPrimaryKey(
213:                        Org.class,
214:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
215:                                .getDepartmentOrgKeys()));
216:                Org newBO = (Org) SpringContext.getBean(
217:                        BusinessObjectService.class).findByPrimaryKey(
218:                        Org.class,
219:                        this .getPrimaryKeysForTopLevelOrg(OrgKeys
220:                                .getDepartmentOrgKeys()));
221:                newBO.setOrganizationDefaultAccountNumber(null); // simulate no organization default account number
222:                maintDoc = this .newMaintDoc(oldBO, newBO);
223:                maintDoc.getNewMaintainableObject().setMaintenanceAction(
224:                        KFSConstants.MAINTENANCE_EDIT_ACTION); // simulate editing
225:                rule = (OrgRule) this 
226:                        .setupMaintDocRule(maintDoc, OrgRule.class);
227:                assertFalse(rule.checkDefaultAccountNumber(maintDoc)); // it is NOT okay for a non-university/non-campus to have no default
228:                // account number
229:            }
230:
231:            private Map getPrimaryKeysForTopLevelOrg(OrgKeys org) {
232:                Map primaryKeys = new HashMap();
233:                primaryKeys.put("chartOfAccountsCode", org.chartOfAccountsCode);
234:                primaryKeys.put("organizationCode", org.organizationCode);
235:                return primaryKeys;
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.