Source Code Cross Referenced for BusinessObjectMetaDataServiceTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » service » 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.service 
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.service;
017:
018:        import java.util.Collection;
019:        import java.util.List;
020:
021:        import org.kuali.core.bo.BusinessObjectRelationship;
022:        import org.kuali.core.bo.user.UniversalUser;
023:        import org.kuali.kfs.bo.Options;
024:        import org.kuali.kfs.context.KualiTestBase;
025:        import org.kuali.kfs.context.SpringContext;
026:        import org.kuali.module.chart.bo.A21SubAccount;
027:        import org.kuali.module.chart.bo.Account;
028:        import org.kuali.module.chart.bo.AccountGuideline;
029:        import org.kuali.module.chart.bo.ObjectCode;
030:        import org.kuali.module.chart.bo.SubAccount;
031:        import org.kuali.module.kra.budget.bo.Budget;
032:        import org.kuali.test.ConfigureContext;
033:        import org.kuali.test.suite.AnnotationTestSuite;
034:        import org.kuali.test.suite.LookupRefactoringSuite;
035:
036:        /**
037:         * This class tests the BusinessObjectMetaDataServiceImpl to make sure that it finds and returns the appropriate meta data for a
038:         * given BO
039:         */
040:        @ConfigureContext
041:        @AnnotationTestSuite(LookupRefactoringSuite.class)
042:        public class BusinessObjectMetaDataServiceTest extends KualiTestBase {
043:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
044:                    .getLogger(BusinessObjectMetaDataServiceTest.class);
045:
046:            public void testGetBusinessObjectMetaDataService() {
047:                BusinessObjectMetaDataService bomd = SpringContext
048:                        .getBean(BusinessObjectMetaDataService.class);
049:                assertNotNull(bomd);
050:            }
051:
052:            public void testGetCollectionNames_oneCollectionItem() {
053:                BusinessObjectMetaDataService bomd = SpringContext
054:                        .getBean(BusinessObjectMetaDataService.class);
055:
056:                // Account has one collection item
057:                Account acct = new Account();
058:                Collection<String> collections = bomd.getCollectionNames(acct);
059:                assertNotNull(collections);
060:                assertTrue(collections.size() == 2);
061:                assertTrue(collections.contains("subAccounts"));
062:                assertTrue(collections.contains("awards"));
063:            }
064:
065:            public void testGetCollectionNames_multipleCollectionItems() {
066:                BusinessObjectMetaDataService bomd = SpringContext
067:                        .getBean(BusinessObjectMetaDataService.class);
068:                // Budget has multiple collection items
069:                Budget budget = new Budget();
070:                Collection<String> collections = bomd
071:                        .getCollectionNames(budget);
072:                assertNotNull(collections);
073:                assertTrue(collections.size() == 2);
074:                assertTrue(collections.contains("tasks"));
075:                assertTrue(collections.contains("periods"));
076:            }
077:
078:            public void testGetCollectionNames_noCollectionItems() {
079:                BusinessObjectMetaDataService bomd = SpringContext
080:                        .getBean(BusinessObjectMetaDataService.class);
081:                // ObjectCode has no collection
082:                ObjectCode objCode = new ObjectCode();
083:                Collection<String> collections = bomd
084:                        .getCollectionNames(objCode);
085:                assertNotNull(collections);
086:                assertTrue(collections.size() == 0);
087:            }
088:
089:            public void testGetInquirableFieldNames() {
090:                BusinessObjectMetaDataService bomd = SpringContext
091:                        .getBean(BusinessObjectMetaDataService.class);
092:
093:                // Account is a good one
094:                // first lookup a field that is in both inquirable and lookupable
095:                // chartOfAccountsCode
096:                Collection<String> fields = bomd.getInquirableFieldNames(
097:                        Account.class, "Account Details");
098:                assertNotNull(fields);
099:                assertTrue(fields.size() > 0);
100:                assertTrue(fields.contains("accountNumber"));
101:
102:                // next lookup a field that is only in inquirable
103:                // pendingAcctSufficientFundsIndicator
104:                assertTrue(fields
105:                        .contains("pendingAcctSufficientFundsIndicator"));
106:
107:                // now search for one that doesn't exist
108:                assertFalse(fields.contains("none"));
109:
110:            }
111:
112:            public void testGetLookupableFieldNames() {
113:                BusinessObjectMetaDataService bomd = SpringContext
114:                        .getBean(BusinessObjectMetaDataService.class);
115:
116:                // Account is a good one
117:                // first lookup a field that is in both inquirable and lookupable
118:                // chartOfAccountsCode
119:                Collection<String> fields = bomd
120:                        .getLookupableFieldNames(Account.class);
121:                assertNotNull(fields);
122:                assertTrue(fields.size() > 0);
123:                assertTrue(fields.contains("chartOfAccountsCode"));
124:
125:                // then one that is only a lookup
126:                assertTrue(fields
127:                        .contains("accountFiscalOfficerSystemIdentifier"));
128:
129:                // compound attribute
130:                assertTrue(fields
131:                        .contains("accountFiscalOfficerUser.personName"));
132:
133:                // look for one that doesn't exist
134:                assertFalse(fields.contains("none"));
135:            }
136:
137:            public void testGetLookupFieldDefaultValue_valueExists() {
138:                BusinessObjectMetaDataService bomd = SpringContext
139:                        .getBean(BusinessObjectMetaDataService.class);
140:
141:                String defaultVal = bomd.getLookupFieldDefaultValue(
142:                        Account.class, "accountClosedIndicator");
143:                assertEquals("N", defaultVal);
144:            }
145:
146:            public void testGetLookupFieldDefaultValue_noValueExists() {
147:                BusinessObjectMetaDataService bomd = SpringContext
148:                        .getBean(BusinessObjectMetaDataService.class);
149:                String noVal = bomd.getLookupFieldDefaultValue(Account.class,
150:                        "subFundGroupCode");
151:                assertEquals(null, noVal);
152:            }
153:
154:            public void testGetLookupFieldDefaultValueFinderClass_valueFinderExists() {
155:                BusinessObjectMetaDataService bomd = SpringContext
156:                        .getBean(BusinessObjectMetaDataService.class);
157:                Class finderClass = bomd.getLookupFieldDefaultValueFinderClass(
158:                        Options.class, "universityFiscalYear");
159:                assertEquals(
160:                        org.kuali.kfs.lookup.valuefinder.FiscalYearFinder.class,
161:                        finderClass);
162:            }
163:
164:            public void testGetLookupFieldDefaultValueFinderClass_valueFinderDoesNotExist() {
165:                BusinessObjectMetaDataService bomd = SpringContext
166:                        .getBean(BusinessObjectMetaDataService.class);
167:                Class finderClass = bomd.getLookupFieldDefaultValueFinderClass(
168:                        Options.class, "universityFinChartOfAcctCd");
169:                assertEquals(null, finderClass);
170:            }
171:
172:            public void testIsAttributeLookupable_noLookupTrue() {
173:                BusinessObjectMetaDataService bomd = SpringContext
174:                        .getBean(BusinessObjectMetaDataService.class);
175:                boolean lookupable = bomd.isAttributeLookupable(Account.class,
176:                        "accountNumber");
177:                assertFalse(lookupable);
178:            }
179:
180:            public void testIsAttributeLookupable_validLookupAttribute() {
181:
182:                BusinessObjectMetaDataService bomd = SpringContext
183:                        .getBean(BusinessObjectMetaDataService.class);
184:                boolean lookupable = bomd.isAttributeLookupable(
185:                        SubAccount.class,
186:                        "a21SubAccount.costShareChartOfAccountCode");
187:
188:                assertTrue(
189:                        "a21SubAccount.costShareChartOfAccountCode should be lookupable",
190:                        lookupable);
191:
192:                lookupable = bomd.isAttributeLookupable(Account.class,
193:                        "chartOfAccountsCode");
194:                assertTrue("chartOfAccountsCode should be lookupable",
195:                        lookupable);
196:
197:                lookupable = bomd.isAttributeLookupable(Account.class,
198:                        "accountFiscalOfficerSystemIdentifier");
199:                assertTrue(
200:                        "accountFiscalOfficerSystemIdentifier should be lookupable",
201:                        lookupable);
202:
203:            }
204:
205:            public void testIsLookupable_validLookup() {
206:                BusinessObjectMetaDataService bomd = SpringContext
207:                        .getBean(BusinessObjectMetaDataService.class);
208:                assertTrue(bomd.isLookupable(Account.class));
209:                assertTrue(bomd.isLookupable(Options.class));
210:            }
211:
212:            public void testIsLookupable_invalidLookup() {
213:                BusinessObjectMetaDataService bomd = SpringContext
214:                        .getBean(BusinessObjectMetaDataService.class);
215:
216:                assertFalse(bomd.isLookupable(A21SubAccount.class));
217:                assertFalse(bomd.isLookupable(AccountGuideline.class));
218:
219:            }
220:
221:            public void testIsAttributeInquirable_noInquiryTrue() {
222:                BusinessObjectMetaDataService bomd = SpringContext
223:                        .getBean(BusinessObjectMetaDataService.class);
224:                // budgetRecordingLevelCode
225:                /*
226:                 * boolean inquirable = bomd.isAttributeInquirable(Account.class, "budgetLevelRecordingCode", "Header Text");
227:                 * assertFalse(inquirable); inquirable = bomd.isAttributeInquirable(Account.class, "accountSufficientFundsCode", "Header
228:                 * Text"); assertFalse(inquirable);
229:                 */
230:                boolean inquirable = bomd.isAttributeInquirable(
231:                        UniversalUser.class, "personUniversalIdentifier",
232:                        "Header Text");
233:                assertFalse(inquirable);
234:
235:            }
236:
237:            public void testGetBusinessObjectRelationships() {
238:                BusinessObjectMetaDataService bomd = SpringContext
239:                        .getBean(BusinessObjectMetaDataService.class);
240:
241:                List<BusinessObjectRelationship> rels = bomd
242:                        .getBusinessObjectRelationships(new Account());
243:                LOG.info(rels);
244:
245:                boolean refFound = false;
246:                BusinessObjectRelationship relationship = null;
247:                for (BusinessObjectRelationship rel : rels) {
248:                    if (rel.getParentAttributeName().equals("chartOfAccounts")) {
249:                        refFound = true;
250:                        relationship = rel;
251:                        LOG.info(rel);
252:                        break;
253:                    }
254:                }
255:                assertTrue(
256:                        "chartOfAccountsCode was not found in reference list",
257:                        refFound);
258:                assertEquals("class name must be account", "Account",
259:                        relationship.getParentClass().getSimpleName());
260:                assertEquals("ref class name must be Chart", "Chart",
261:                        relationship.getRelatedClass().getSimpleName());
262:                assertEquals(
263:                        "chartOfAccountsCode must map to chartOfAccountsCode",
264:                        "chartOfAccountsCode", relationship
265:                                .getParentToChildReferences().get(
266:                                        "chartOfAccountsCode"));
267:
268:                refFound = false;
269:                relationship = null;
270:                for (BusinessObjectRelationship rel : rels) {
271:                    if (rel.getParentToChildReferences().containsKey(
272:                            "accountFiscalOfficerSystemIdentifier")) {
273:                        refFound = true;
274:                        relationship = rel;
275:                        LOG.info(rel);
276:                        break;
277:                    }
278:                }
279:
280:                assertTrue(
281:                        "accountFiscalOfficerSystemIdentifier was not found in reference list",
282:                        refFound);
283:                assertEquals("class name must be account", "Account",
284:                        relationship.getParentClass().getSimpleName());
285:                assertEquals("ref class name must be UniversalUser",
286:                        "UniversalUser", relationship.getRelatedClass()
287:                                .getSimpleName());
288:                assertEquals(
289:                        "accountFiscalOfficerSystemIdentifier must map to personUniversalIdentifier",
290:                        "personUniversalIdentifier", relationship
291:                                .getParentToChildReferences().get(
292:                                        "accountFiscalOfficerSystemIdentifier"));
293:            }
294:
295:            /*
296:             * public void testIsAttributeInquirable_validInquiryAttribute() { BusinessObjectMetaDataService bomd =
297:             * SpringContext.getBean(BusinessObjectMetaDataService.class); //budgetRecordingLevelCode boolean inquirable =
298:             * bomd.isAttributeInquirable(Account.class, "contractControlFinCoaCode", "Header Text"); assertTrue(inquirable); inquirable =
299:             * bomd.isAttributeInquirable(Account.class, "accountPhysicalCampusCode", "Header Text"); assertTrue(inquirable); inquirable =
300:             * bomd.isAttributeInquirable(UniversalUser.class, "employeeTypeCode", "Header Text"); assertTrue(inquirable); }
301:             */
302:
303:            /*
304:             * public void testIsInquirable() { //fail("Not yet implemented"); } public void testGetRelatedReferenceClass() { //fail("Not
305:             * yet implemented"); } public void testIsNestedAttributeInquirable() { //fail("Not yet implemented"); } public void
306:             * testIsNestedAttributeLookupable() { //fail("Not yet implemented"); } public void testGetQuickFinderClass() { //fail("Not yet
307:             * implemented"); }
308:             */
309:
310:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.