Source Code Cross Referenced for ExtensionAttributeTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » datadictionary » 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.core.datadictionary 
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.core.datadictionary;
017:
018:        import java.util.ArrayList;
019:
020:        import org.apache.commons.beanutils.PropertyUtils;
021:        import org.apache.log4j.Level;
022:        import org.junit.After;
023:        import org.junit.Before;
024:        import org.junit.Test;
025:        import org.kuali.core.UserSession;
026:        import org.kuali.core.bo.BusinessObject;
027:        import org.kuali.core.bo.BusinessObjectRelationship;
028:        import org.kuali.core.bo.PersistableBusinessObjectExtension;
029:        import org.kuali.core.document.MaintenanceDocument;
030:        import org.kuali.core.exceptions.ValidationException;
031:        import org.kuali.core.lookup.LookupUtils;
032:        import org.kuali.core.rule.event.RouteDocumentEvent;
033:        import org.kuali.core.util.FieldUtils;
034:        import org.kuali.core.util.GlobalVariables;
035:        import org.kuali.core.util.ObjectUtils;
036:        import org.kuali.core.web.ui.Field;
037:        import org.kuali.rice.KNSServiceLocator;
038:        import org.kuali.test.KNSTestBase;
039:
040:        import edu.sampleu.travel.bo.TravelAccount;
041:        import edu.sampleu.travel.bo.TravelAccountExtension;
042:        import edu.sampleu.travel.bo.TravelAccountType;
043:
044:        public class ExtensionAttributeTest extends KNSTestBase {
045:
046:            DataDictionaryBuilder builder = null;
047:
048:            @Before
049:            public void setUp() throws Exception {
050:                super .setUp();
051:
052:                builder = new DataDictionaryBuilder(KNSServiceLocator
053:                        .getValidationCompletionUtils());
054:                builder
055:                        .addUniqueEntries(
056:                                "classpath:org/kuali/core/bo/datadictionary/AdHocRoutePerson.xml",
057:                                true);
058:                builder
059:                        .addUniqueEntries(
060:                                "classpath:org/kuali/core/bo/datadictionary/AdHocRouteWorkgroup.xml",
061:                                true);
062:                builder
063:                        .addUniqueEntries(
064:                                "classpath:org/kuali/core/bo/datadictionary/Attachment.xml",
065:                                true);
066:                builder
067:                        .addUniqueEntries(
068:                                "classpath:org/kuali/core/bo/datadictionary/AttributeReferenceDummy.xml",
069:                                true);
070:                builder
071:                        .addUniqueEntries(
072:                                "classpath:org/kuali/core/bo/datadictionary/BusinessObjectAttributeEntry.xml",
073:                                true);
074:                //builder.addUniqueEntries("classpath:org/kuali/core/bo/datadictionary/BusinessRule.xml", true);
075:                //builder.addUniqueEntries("classpath:org/kuali/core/bo/datadictionary/BusinessRuleSecurity.xml", true);
076:                builder
077:                        .addUniqueEntries(
078:                                "classpath:org/kuali/core/bo/datadictionary/Campus.xml",
079:                                true);
080:                builder
081:                        .addUniqueEntries(
082:                                "classpath:org/kuali/core/bo/datadictionary/CampusType.xml",
083:                                true);
084:                builder
085:                        .addUniqueEntries(
086:                                "classpath:org/kuali/core/bo/datadictionary/DocumentGroup.xml",
087:                                true);
088:                builder
089:                        .addUniqueEntries(
090:                                "classpath:org/kuali/core/bo/datadictionary/DocumentHeader.xml",
091:                                true);
092:                builder
093:                        .addUniqueEntries(
094:                                "classpath:org/kuali/core/bo/datadictionary/DocumentStatus.xml",
095:                                true);
096:                builder
097:                        .addUniqueEntries(
098:                                "classpath:org/kuali/core/bo/datadictionary/DocumentType.xml",
099:                                true);
100:                builder
101:                        .addUniqueEntries(
102:                                "classpath:org/kuali/core/bo/datadictionary/EmployeeStatus.xml",
103:                                true);
104:                builder
105:                        .addUniqueEntries(
106:                                "classpath:org/kuali/core/bo/datadictionary/EmployeeType.xml",
107:                                true);
108:                //builder.addUniqueEntries("classpath:org/kuali/core/bo/datadictionary/FinancialSystemParameter.xml", true);
109:                //builder.addUniqueEntries("classpath:org/kuali/core/bo/datadictionary/FinancialSystemParameterSecurity.xml", true);
110:                builder.addUniqueEntries(
111:                        "classpath:org/kuali/core/bo/datadictionary/Note.xml",
112:                        true);
113:                builder
114:                        .addUniqueEntries(
115:                                "classpath:org/kuali/core/bo/datadictionary/NoteType.xml",
116:                                true);
117:                builder
118:                        .addUniqueEntries(
119:                                "classpath:org/kuali/core/bo/datadictionary/UniversalUser.xml",
120:                                true);
121:                //builder.addUniqueEntries("classpath:org/kuali/core/document/datadictionary/BusinessRuleMaintenanceDocument.xml", true);
122:                //builder.addUniqueEntries("classpath:org/kuali/core/document/datadictionary/BusinessRuleSecurityMaintenanceDocument.xml", true);
123:                builder
124:                        .addUniqueEntries(
125:                                "classpath:org/kuali/core/document/datadictionary/CampusMaintenanceDocument.xml",
126:                                true);
127:                builder
128:                        .addUniqueEntries(
129:                                "classpath:org/kuali/core/document/datadictionary/CampusTypeMaintenanceDocument.xml",
130:                                true);
131:                builder
132:                        .addUniqueEntries(
133:                                "classpath:org/kuali/core/document/datadictionary/DocumentTypeMaintenanceDocument.xml",
134:                                true);
135:                builder
136:                        .addUniqueEntries(
137:                                "classpath:org/kuali/core/document/datadictionary/EmployeeStatusMaintenanceDocument.xml",
138:                                true);
139:                builder
140:                        .addUniqueEntries(
141:                                "classpath:org/kuali/core/document/datadictionary/EmployeeTypeMaintenanceDocument.xml",
142:                                true);
143:                //builder.addUniqueEntries("classpath:org/kuali/core/document/datadictionary/FinancialSystemParameterSecurityMaintenanceDocument.xml", true);
144:                //builder.addUniqueEntries("classpath:org/kuali/core/document/datadictionary/FinancialSystemParameterMaintenanceDocument.xml", true);
145:                builder
146:                        .addUniqueEntries(
147:                                "classpath:org/kuali/core/document/datadictionary/UniversalUserMaintenanceDocument.xml",
148:                                true);
149:                builder
150:                        .addUniqueEntries(
151:                                "classpath:edu/sampleu/travel/datadictionary/TravelAccount.xml",
152:                                true);
153:                builder
154:                        .addUniqueEntries(
155:                                "classpath:edu/sampleu/travel/datadictionary/TravelAccountType.xml",
156:                                true);
157:                builder
158:                        .addUniqueEntries(
159:                                "classpath:edu/sampleu/travel/datadictionary/TravelAccountMaintenanceDocument.xml",
160:                                true);
161:                builder
162:                        .addUniqueEntries(
163:                                "classpath:edu/sampleu/travel/datadictionary/TravelAccountExtension.xml",
164:                                true);
165:                builder
166:                        .addUniqueEntries(
167:                                "classpath:edu/sampleu/travel/datadictionary/FiscalOfficer.xml",
168:                                true);
169:                builder
170:                        .addUniqueEntries(
171:                                "classpath:edu/sampleu/travel/datadictionary/FiscalOfficerMaintenanceDocument.xml",
172:                                true);
173:
174:                // quieten things down a bit
175:                setLogLevel("org.apache.commons.digester", Level.ERROR);
176:                setLogLevel("org.kuali.core.datadictionary.XmlErrorHandler",
177:                        Level.ERROR);
178:            }
179:
180:            @After
181:            public void tearDown() throws Exception {
182:                super .tearDown();
183:                builder = null;
184:            }
185:
186:            @Test
187:            public void testExtensionAttributeType() throws Exception {
188:                BusinessObjectEntry boe = builder.getDataDictionary()
189:                        .getBusinessObjectEntry("TravelAccount");
190:                assertNotNull(
191:                        "BusinessObjectEntry for TravelAccount should not be null",
192:                        boe);
193:                AttributeDefinition extAttrib = boe
194:                        .getAttributeDefinition("extension.accountTypeCode");
195:                assertNotNull(
196:                        "AttributeDefinition for 'extension.accountType' should not be null",
197:                        extAttrib);
198:                extAttrib = boe
199:                        .getAttributeDefinition("extension.accountType.codeAndDescription");
200:                assertNotNull(
201:                        "AttributeDefinition for 'extension.accountType.codeAndDescription' should not be null",
202:                        extAttrib);
203:            }
204:
205:            @Test
206:            public void testObjectUtils_getPropertyType() throws Exception {
207:                TravelAccount ta = new TravelAccount();
208:                assertEquals("physical property type mismatch",
209:                        PersistableBusinessObjectExtension.class, PropertyUtils
210:                                .getPropertyType(ta, "extension"));
211:                assertEquals("DD property type mismatch",
212:                        TravelAccountExtension.class,
213:                        ObjectUtils.getPropertyType(ta, "extension",
214:                                KNSServiceLocator
215:                                        .getPersistenceStructureService()));
216:                assertEquals("extension.accountType attribute class mismatch",
217:                        TravelAccountType.class, ObjectUtils.getPropertyType(
218:                                ta, "extension.accountType", KNSServiceLocator
219:                                        .getPersistenceStructureService()));
220:                assertEquals(
221:                        "extension.accountType.codeAndDescription attribute class mismatch",
222:                        String.class, ObjectUtils.getPropertyType(ta,
223:                                "extension.accountType.codeAndDescription",
224:                                KNSServiceLocator
225:                                        .getPersistenceStructureService()));
226:            }
227:
228:            @Test
229:            public void testBOMetaDataService() throws Exception {
230:                TravelAccount ta = new TravelAccount();
231:                BusinessObjectRelationship br = KNSServiceLocator
232:                        .getBusinessObjectMetaDataService()
233:                        .getBusinessObjectRelationship(ta,
234:                                "extension.accountType");
235:                assertEquals("mismatch on parent class", TravelAccount.class,
236:                        br.getParentClass());
237:                assertEquals("mismatch on related class",
238:                        TravelAccountType.class, br.getRelatedClass());
239:                System.out.println(br.getParentToChildReferences());
240:                assertEquals(
241:                        "parent/child key not correct - should be extension.accountTypeCode/accountTypeCode",
242:                        "accountTypeCode", br.getParentToChildReferences().get(
243:                                "extension.accountTypeCode"));
244:                br = KNSServiceLocator.getBusinessObjectMetaDataService()
245:                        .getBusinessObjectRelationship(ta, "extension");
246:                assertNull(
247:                        "extension is not lookupable, should have returned null",
248:                        br);
249:            }
250:
251:            @Test
252:            public void testQuickFinder() throws Exception {
253:                TravelAccount ta = new TravelAccount();
254:                ArrayList<String> lookupFieldAttributeList = new ArrayList<String>();
255:                lookupFieldAttributeList.add("extension.accountTypeCode");
256:
257:                Field field = FieldUtils.getPropertyField(ta.getClass(),
258:                        "extension.accountTypeCode", true);
259:
260:                field = LookupUtils.setFieldQuickfinder((BusinessObject) ta,
261:                        "extension.accountTypeCode", field,
262:                        lookupFieldAttributeList);
263:
264:                assertEquals("lookup class not correct",
265:                        TravelAccountType.class.getName(), field
266:                                .getQuickFinderClassNameImpl());
267:                assertEquals("field lookup params not correct",
268:                        "extension.accountTypeCode:accountTypeCode", field
269:                                .getLookupParameters());
270:                assertEquals("lookup field conversions not correct",
271:                        "accountTypeCode:extension.accountTypeCode", field
272:                                .getFieldConversions());
273:            }
274:
275:            @Test
276:            public void testExistenceChecks() throws Exception {
277:                TravelAccount ta = new TravelAccount();
278:                ((TravelAccountExtension) ta.getExtension())
279:                        .setAccountTypeCode("XYZ"); // invalid account type
280:                ta.setName("Test Name");
281:                ta.setNumber("1234567");
282:                GlobalVariables.setUserSession(new UserSession("quickstart"));
283:                MaintenanceDocument document = (MaintenanceDocument) KNSServiceLocator
284:                        .getDocumentService().getNewDocument(
285:                                "TravelAccountMaintenanceDocument");
286:                assertNotNull("new document must not be null", document);
287:                document.getDocumentHeader().setFinancialDocumentDescription(
288:                        getClass().getSimpleName() + "test");
289:                document.getOldMaintainableObject().setBusinessObject(null);
290:                document.getOldMaintainableObject().setBoClass(ta.getClass());
291:                document.getNewMaintainableObject().setBusinessObject(ta);
292:                document.getNewMaintainableObject().setBoClass(ta.getClass());
293:
294:                boolean failedAsExpected = false;
295:                try {
296:                    document.validateBusinessRules(new RouteDocumentEvent(
297:                            document));
298:                } catch (ValidationException expected) {
299:                    failedAsExpected = true;
300:                }
301:                assertTrue("validation should have failed", failedAsExpected);
302:                System.out.println("document errors: "
303:                        + GlobalVariables.getErrorMap());
304:                assertTrue("there should be errors", GlobalVariables
305:                        .getErrorMap().getErrorCount() > 0);
306:                assertTrue(
307:                        "should be an error on the account type code",
308:                        GlobalVariables
309:                                .getErrorMap()
310:                                .containsKey(
311:                                        "document.newMaintainableObject.extension.accountTypeCode"));
312:                assertTrue(
313:                        "account type code should have an existence error",
314:                        GlobalVariables
315:                                .getErrorMap()
316:                                .fieldHasMessage(
317:                                        "document.newMaintainableObject.extension.accountTypeCode",
318:                                        "error.existence"));
319:            }
320:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.