Source Code Cross Referenced for LookupUtilsTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » lookup » 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.lookup 
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.lookup;
017:
018:        import java.util.ArrayList;
019:        import java.util.List;
020:
021:        import org.kuali.core.bo.Campus;
022:        import org.kuali.core.bo.user.UniversalUser;
023:        import org.kuali.core.service.BusinessObjectMetaDataService;
024:        import org.kuali.core.util.FieldUtils;
025:        import org.kuali.core.web.ui.Field;
026:        import org.kuali.kfs.bo.Options;
027:        import org.kuali.kfs.context.KualiTestBase;
028:        import org.kuali.kfs.context.SpringContext;
029:        import org.kuali.module.chart.bo.Account;
030:        import org.kuali.module.chart.bo.Chart;
031:        import org.kuali.module.chart.bo.Org;
032:        import org.kuali.module.chart.bo.SubAccount;
033:        import org.kuali.module.chart.bo.SubFundGroup;
034:        import org.kuali.module.gl.bo.AccountBalancePendingEntry;
035:        import org.kuali.module.vendor.bo.VendorAddress;
036:        import org.kuali.module.vendor.bo.VendorDefaultAddress;
037:        import org.kuali.module.vendor.bo.VendorDetail;
038:        import org.kuali.test.ConfigureContext;
039:        import org.kuali.test.suite.AnnotationTestSuite;
040:        import org.kuali.test.suite.LookupRefactoringSuite;
041:
042:        /**
043:         * This class tests the LookupUtils to make sure that it works properly
044:         */
045:        @ConfigureContext
046:        @AnnotationTestSuite(LookupRefactoringSuite.class)
047:        public class LookupUtilsTest extends KualiTestBase {
048:
049:            public void testSetFieldQuickfinder_nonNestedAttributesValid() {
050:                // testing chartOfAccountsCode lookup
051:                Account acct = new Account();
052:                Field field = FieldUtils.getPropertyField(acct.getClass(),
053:                        "chartOfAccountsCode", true);
054:                List<String> lookupFieldAttributeList = SpringContext.getBean(
055:                        BusinessObjectMetaDataService.class)
056:                        .getLookupableFieldNames(acct.getClass());
057:                LookupUtils.setFieldQuickfinder(acct, "chartOfAccountsCode",
058:                        field, lookupFieldAttributeList);
059:                assertEquals(Chart.class.getName(), field
060:                        .getQuickFinderClassNameImpl());
061:
062:                // subFundGroupCode
063:                field = FieldUtils.getPropertyField(acct.getClass(),
064:                        "subFundGroupCode", true);
065:                lookupFieldAttributeList = SpringContext.getBean(
066:                        BusinessObjectMetaDataService.class)
067:                        .getLookupableFieldNames(acct.getClass());
068:                LookupUtils.setFieldQuickfinder(acct, "subFundGroupCode",
069:                        field, lookupFieldAttributeList);
070:                assertEquals(SubFundGroup.class.getName(), field
071:                        .getQuickFinderClassNameImpl());
072:
073:                // organizationCode
074:                field = FieldUtils.getPropertyField(acct.getClass(),
075:                        "organizationCode", true);
076:                lookupFieldAttributeList = SpringContext.getBean(
077:                        BusinessObjectMetaDataService.class)
078:                        .getLookupableFieldNames(acct.getClass());
079:                LookupUtils.setFieldQuickfinder(acct, "organizationCode",
080:                        field, lookupFieldAttributeList);
081:                assertEquals(Org.class.getName(), field
082:                        .getQuickFinderClassNameImpl());
083:            }
084:
085:            public void testSetFieldQuickfinder_nonNestedAttributesInvalid() {
086:                // testing chartOfAccountsCode lookup
087:                Account acct = new Account();
088:
089:                Field field = FieldUtils.getPropertyField(acct.getClass(),
090:                        "accountNumber", true);
091:                List<String> lookupFieldAttributeList = SpringContext.getBean(
092:                        BusinessObjectMetaDataService.class)
093:                        .getLookupableFieldNames(acct.getClass());
094:                LookupUtils.setFieldQuickfinder(acct, "accountNumber", field,
095:                        lookupFieldAttributeList);
096:                assertEquals(null, field.getQuickFinderClassNameImpl());
097:
098:                // universityFiscalYearName on Options
099:                Options options = new Options();
100:                field = FieldUtils.getPropertyField(options.getClass(),
101:                        "universityFiscalYearName", true);
102:                lookupFieldAttributeList = SpringContext.getBean(
103:                        BusinessObjectMetaDataService.class)
104:                        .getLookupableFieldNames(options.getClass());
105:                LookupUtils.setFieldQuickfinder(options,
106:                        "universityFiscalYearName", field,
107:                        lookupFieldAttributeList);
108:                assertEquals(null, field.getQuickFinderClassNameImpl());
109:
110:                // organizationCode on Org
111:                Org org = new Org();
112:                field = FieldUtils.getPropertyField(org.getClass(),
113:                        "organizationCode", true);
114:                lookupFieldAttributeList = SpringContext.getBean(
115:                        BusinessObjectMetaDataService.class)
116:                        .getLookupableFieldNames(org.getClass());
117:                LookupUtils.setFieldQuickfinder(org, "organizationCode", field,
118:                        lookupFieldAttributeList);
119:                assertEquals(null, field.getQuickFinderClassNameImpl());
120:
121:                // add one in here for Universal User?
122:            }
123:
124:            public void testSetFieldQuickfinder_nonNestedAttributesNoLookupTrue() {
125:                // testing chartOfAccountsCode lookup
126:                Account acct = new Account();
127:                Field field = FieldUtils.getPropertyField(acct.getClass(),
128:                        "accountNumber", true);
129:                List<String> lookupFieldAttributeList = SpringContext.getBean(
130:                        BusinessObjectMetaDataService.class)
131:                        .getLookupableFieldNames(acct.getClass());
132:                LookupUtils.setFieldQuickfinder(acct, "accountNumber", field,
133:                        lookupFieldAttributeList);
134:                assertEquals(null, field.getQuickFinderClassNameImpl());
135:
136:                AccountBalancePendingEntry pending = new AccountBalancePendingEntry();
137:                // universityFiscalYear on the AccountBalancePendingEntry
138:                field = FieldUtils.getPropertyField(pending.getClass(),
139:                        "universityFiscalYear", true);
140:                lookupFieldAttributeList = SpringContext.getBean(
141:                        BusinessObjectMetaDataService.class)
142:                        .getLookupableFieldNames(pending.getClass());
143:                LookupUtils.setFieldQuickfinder(acct, "universityFiscalYear",
144:                        field, lookupFieldAttributeList);
145:                assertEquals(null, field.getQuickFinderClassNameImpl());
146:            }
147:
148:            public void testSetFieldQuickfinder_reportsToAccount() {
149:                // testing reportsToAccountNumber lookup
150:                Account acct = new Account();
151:                Field field = FieldUtils.getPropertyField(acct.getClass(),
152:                        "reportsToAccountNumber", true);
153:                List<String> lookupFieldAttributeList = SpringContext.getBean(
154:                        BusinessObjectMetaDataService.class)
155:                        .getLookupableFieldNames(acct.getClass());
156:                LookupUtils.setFieldQuickfinder(acct, "reportsToAccountNumber",
157:                        field, lookupFieldAttributeList);
158:                // should be account object
159:                assertEquals(Account.class.getName(), field
160:                        .getQuickFinderClassNameImpl());
161:                assertTrue("fieldConversions incorrect - was: "
162:                        + field.getFieldConversions(), field
163:                        .getFieldConversions().contains(
164:                                "accountNumber:reportsToAccountNumber"));
165:                assertTrue("lookupParameters incorrect - was: "
166:                        + field.getLookupParameters(), field
167:                        .getLookupParameters().contains(
168:                                "reportsToAccountNumber:accountNumber"));
169:
170:            }
171:
172:            public void testSetFieldQuickfinder_nestedAttributesValid() {
173:                // testing chartOfAccountsCode lookup
174:                SubAccount subAcct = new SubAccount();
175:                Field field = FieldUtils.getPropertyField(subAcct.getClass(),
176:                        "a21SubAccount.costShareChartOfAccountCode", true);
177:                List<String> lookupFieldAttributeList = SpringContext.getBean(
178:                        BusinessObjectMetaDataService.class)
179:                        .getLookupableFieldNames(subAcct.getClass());
180:                LookupUtils.setFieldQuickfinder(subAcct,
181:                        "a21SubAccount.costShareChartOfAccount", field,
182:                        lookupFieldAttributeList);
183:                // should be chart object
184:                assertEquals(Chart.class.getName(), field
185:                        .getQuickFinderClassNameImpl());
186:                assertEquals(
187:                        "chartOfAccountsCode:a21SubAccount.costShareChartOfAccountCode",
188:                        field.getFieldConversions());
189:                assertEquals(
190:                        "a21SubAccount.costShareChartOfAccountCode:chartOfAccountsCode",
191:                        field.getLookupParameters());
192:
193:            }
194:
195:            public void testSetFieldQuickfinder_nestedAttributesInvalid() {
196:                // testing chartOfAccountsCode lookup
197:                Account acct = new Account();
198:                Field field = FieldUtils.getPropertyField(acct.getClass(),
199:                        "chartOfAccounts.codeAndDescription", true);
200:                List<String> lookupFieldAttributeList = SpringContext.getBean(
201:                        BusinessObjectMetaDataService.class)
202:                        .getLookupableFieldNames(acct.getClass());
203:                LookupUtils.setFieldQuickfinder(acct,
204:                        "chartOfAccounts.codeAndDescription", field,
205:                        lookupFieldAttributeList);
206:                // should be chart object
207:                assertEquals(Chart.class.getName(), field
208:                        .getQuickFinderClassNameImpl());
209:                System.out
210:                        .println("chartOfAccounts.codeAndDescription lookupParams: "
211:                                + field.getLookupParameters());
212:                System.out
213:                        .println("chartOfAccounts.codeAndDescription fieldConvs  : "
214:                                + field.getFieldConversions());
215:            }
216:
217:            /**
218:             * testing accountFiscalOfficerUser.personUserIdentifier lookup
219:             */
220:            public void testSetFieldQuickfinder_specialCases() {
221:                Account acct = new Account();
222:                Field field = FieldUtils.getPropertyField(acct.getClass(),
223:                        "accountFiscalOfficerUser.personUserIdentifier", true);
224:                List<String> lookupFieldAttributeList = SpringContext.getBean(
225:                        BusinessObjectMetaDataService.class)
226:                        .getLookupableFieldNames(acct.getClass());
227:                LookupUtils.setFieldQuickfinder(acct,
228:                        "accountFiscalOfficerUser.personUserIdentifier", field,
229:                        lookupFieldAttributeList);
230:                assertEquals(UniversalUser.class.getName(), field
231:                        .getQuickFinderClassNameImpl());
232:                assertTrue(
233:                        "fieldConversions incorrect - was: "
234:                                + field.getFieldConversions(),
235:                        field
236:                                .getFieldConversions()
237:                                .contains(
238:                                        "personUniversalIdentifier:accountFiscalOfficerSystemIdentifier"));
239:                assertTrue(
240:                        "fieldConversions incorrect - was: "
241:                                + field.getFieldConversions(),
242:                        field
243:                                .getFieldConversions()
244:                                .contains(
245:                                        "personUserIdentifier:accountFiscalOfficerUser.personUserIdentifier"));
246:                assertTrue(
247:                        "fieldConversions incorrect - was: "
248:                                + field.getFieldConversions(),
249:                        field
250:                                .getFieldConversions()
251:                                .contains(
252:                                        "personName:accountFiscalOfficerUser.personName"));
253:                assertTrue(
254:                        "lookupParameters incorrect - was: "
255:                                + field.getLookupParameters(),
256:                        field
257:                                .getLookupParameters()
258:                                .contains(
259:                                        "accountFiscalOfficerUser.personUserIdentifier:personUserIdentifier"));
260:            }
261:
262:            public void testSetFieldQuickfinder_vendor() {
263:                VendorDetail vd = new VendorDetail();
264:                List<VendorAddress> vas = new ArrayList<VendorAddress>();
265:                vd.setVendorAddresses(vas);
266:                VendorAddress va = new VendorAddress();
267:                vas.add(va);
268:                VendorDefaultAddress vda = new VendorDefaultAddress();
269:                List<VendorDefaultAddress> vdas = new ArrayList<VendorDefaultAddress>();
270:                vdas.add(vda);
271:                va.setVendorDefaultAddresses(vdas);
272:
273:                String vendorDefaultAddressCampusCodePropertyName = "vendorCampusCode";
274:                Field field = FieldUtils.getPropertyField(vda.getClass(),
275:                        vendorDefaultAddressCampusCodePropertyName, true);
276:
277:                List<String> lookupFieldAttributeList = SpringContext.getBean(
278:                        BusinessObjectMetaDataService.class)
279:                        .getLookupableFieldNames(Campus.class);
280:                LookupUtils.setFieldQuickfinder(vda,
281:                        "vendorAddresses[0].vendorDefaultAddresses", true, 0,
282:                        vendorDefaultAddressCampusCodePropertyName, field,
283:                        lookupFieldAttributeList);
284:
285:                assertNotNull("quickfinder class was null", field
286:                        .getQuickFinderClassNameImpl());
287:                assertEquals(Campus.class.getName(), field
288:                        .getQuickFinderClassNameImpl());
289:                assertEquals("campusCode:"
290:                        + "add.vendorAddresses[0].vendorDefaultAddresses."
291:                        + vendorDefaultAddressCampusCodePropertyName, field
292:                        .getFieldConversions());
293:                assertEquals("add.vendorAddresses[0].vendorDefaultAddresses."
294:                        + vendorDefaultAddressCampusCodePropertyName
295:                        + ":campusCode", field.getLookupParameters());
296:
297:                LookupUtils.setFieldQuickfinder(vda,
298:                        "vendorAddresses[0].vendorDefaultAddresses", false, 0,
299:                        vendorDefaultAddressCampusCodePropertyName, field,
300:                        lookupFieldAttributeList);
301:
302:                assertNotNull("quickfinder class was null", field
303:                        .getQuickFinderClassNameImpl());
304:                assertEquals(Campus.class.getName(), field
305:                        .getQuickFinderClassNameImpl());
306:                assertEquals("campusCode:"
307:                        + "vendorAddresses[0].vendorDefaultAddresses[0]."
308:                        + vendorDefaultAddressCampusCodePropertyName, field
309:                        .getFieldConversions());
310:                assertEquals("vendorAddresses[0].vendorDefaultAddresses[0]."
311:                        + vendorDefaultAddressCampusCodePropertyName
312:                        + ":campusCode", field.getLookupParameters());
313:
314:            }
315:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.