Source Code Cross Referenced for CurrentFundsLookupableHelperServiceTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » web » lookupable » 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.labor.web.lookupable 
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.module.labor.web.lookupable;
017:
018:        import java.util.ArrayList;
019:        import java.util.Arrays;
020:        import java.util.HashMap;
021:        import java.util.List;
022:        import java.util.Map;
023:        import java.util.Properties;
024:
025:        import org.apache.commons.lang.StringUtils;
026:        import org.kuali.core.lookup.LookupableHelperService;
027:        import org.kuali.core.service.BusinessObjectService;
028:        import org.kuali.core.service.PersistenceService;
029:        import org.kuali.kfs.KFSPropertyConstants;
030:        import org.kuali.kfs.context.KualiTestBase;
031:        import org.kuali.kfs.context.SpringContext;
032:        import org.kuali.kfs.lookup.LookupableSpringContext;
033:        import org.kuali.module.gl.web.Constant;
034:        import org.kuali.module.gl.web.TestDataGenerator;
035:        import org.kuali.module.labor.LaborConstants;
036:        import org.kuali.module.labor.bo.AccountStatusCurrentFunds;
037:        import org.kuali.module.labor.bo.CalculatedSalaryFoundationTracker;
038:        import org.kuali.module.labor.bo.LedgerBalance;
039:        import org.kuali.module.labor.service.LaborInquiryOptionsService;
040:        import org.kuali.module.labor.util.ObjectUtil;
041:        import org.kuali.test.ConfigureContext;
042:
043:        /**
044:         * This class contains test cases that can be applied to methods in Account Status Current Funds class.
045:         */
046:        @ConfigureContext
047:        public class CurrentFundsLookupableHelperServiceTest extends
048:                KualiTestBase {
049:            private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
050:                    .getLog(CurrentFundsLookupableHelperServiceTest.class);
051:            private BusinessObjectService businessObjectService;
052:            private LookupableHelperService lookupableHelperService;
053:            private PersistenceService persistenceService;
054:
055:            private Properties properties;
056:            private String fieldNames, documentFieldNames;
057:            private String deliminator;
058:            private int currentFundsNumberOfTestData;
059:            private int currentFundsExpectedInsertion;
060:
061:            /**
062:             * Get ready for the test
063:             */
064:            @Override
065:            protected void setUp() throws Exception {
066:                super .setUp();
067:
068:                businessObjectService = SpringContext
069:                        .getBean(BusinessObjectService.class);
070:
071:                lookupableHelperService = LookupableSpringContext
072:                        .getLookupableHelperService(LaborConstants.CURRENT_FUNDS_LOOKUP_HELPER_SRVICE_NAME);
073:                lookupableHelperService
074:                        .setBusinessObjectClass(AccountStatusCurrentFunds.class);
075:
076:                // Clear up the data so that any existing data cannot affact your test result
077:                Map keys = new HashMap();
078:                keys.put(KFSPropertyConstants.ACCOUNT_NUMBER, "6044906");
079:                keys.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, "2004");
080:                keys.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, "BA");
081:                businessObjectService.deleteMatching(LedgerBalance.class, keys);
082:            }
083:
084:            /**
085:             * This method will run the current funds balance inquiry to test that the CurrentFundsLookupableHelperService is returning data
086:             * correctly.
087:             * 
088:             * @throws Exception
089:             */
090:            public void testGetSearchResults() throws Exception {
091:                insertCurrentFundsRecords();
092:                AccountStatusCurrentFunds accountStatusCurrentFunds = new AccountStatusCurrentFunds();
093:                accountStatusCurrentFunds.setAccountNumber("6044906");
094:                accountStatusCurrentFunds.setUniversityFiscalYear(2004);
095:                accountStatusCurrentFunds.setChartOfAccountsCode("BA");
096:
097:                // test the search results before the specified entry is inserted
098:                Map fieldValues = buildFieldValues(accountStatusCurrentFunds,
099:                        this .getLookupFields(false));
100:
101:                // Tells the lookupable I want detailed results
102:                getInquiryOptionsService().getConsolidationField(
103:                        lookupableHelperService.getRows()).setPropertyValue(
104:                        Constant.DETAIL);
105:                fieldValues.put(Constant.CONSOLIDATION_OPTION, Constant.DETAIL);
106:
107:                List<String> groupByList = new ArrayList<String>();
108:                List<AccountStatusCurrentFunds> searchResults = lookupableHelperService
109:                        .getSearchResults(fieldValues);
110:
111:                // Make sure the basic search parameters are returned from the inquiry
112:                for (AccountStatusCurrentFunds accountStatusCurrentFundsReturn : searchResults) {
113:                    assertFalse(!(accountStatusCurrentFundsReturn
114:                            .getAccountNumber().equals(
115:                                    accountStatusCurrentFunds
116:                                            .getAccountNumber())
117:                            && accountStatusCurrentFundsReturn
118:                                    .getUniversityFiscalYear().equals(
119:                                            accountStatusCurrentFunds
120:                                                    .getUniversityFiscalYear()) && accountStatusCurrentFundsReturn
121:                            .getChartOfAccountsCode().equals(
122:                                    accountStatusCurrentFunds
123:                                            .getChartOfAccountsCode())));
124:                }
125:
126:                if (searchResults != null) {
127:                    System.out.println("Results Size:" + searchResults.size());
128:                }
129:
130:                // compare the search results with the expected and see if they match with each other
131:                assertEquals(this .currentFundsExpectedInsertion, searchResults
132:                        .size());
133:            }
134:
135:            /**
136:             * This method will run the current funds balance inquiry to test that the CurrentFundsLookupableHelperService is returning data
137:             * correctly.
138:             * 
139:             * @throws Exception
140:             */
141:            public void testGetSearchResultsConsolidated() throws Exception {
142:                insertCurrentFundsRecords();
143:                AccountStatusCurrentFunds accountStatusCurrentFunds = new AccountStatusCurrentFunds();
144:                accountStatusCurrentFunds.setAccountNumber("6044906");
145:                accountStatusCurrentFunds.setUniversityFiscalYear(2004);
146:                accountStatusCurrentFunds.setChartOfAccountsCode("BA");
147:
148:                // test the search results before the specified entry is inserted
149:                Map fieldValues = buildFieldValues(accountStatusCurrentFunds,
150:                        this .getLookupFields(false));
151:
152:                // Tells the lookupable I want consolidated results
153:                getInquiryOptionsService().getConsolidationField(
154:                        lookupableHelperService.getRows()).setPropertyValue(
155:                        Constant.CONSOLIDATION);
156:                fieldValues.put(Constant.CONSOLIDATION_OPTION,
157:                        Constant.CONSOLIDATION);
158:
159:                List<String> groupByList = new ArrayList<String>();
160:                List<AccountStatusCurrentFunds> searchResults = lookupableHelperService
161:                        .getSearchResults(fieldValues);
162:
163:                // Make sure the basic search parameters are returned from the inquiry
164:                for (AccountStatusCurrentFunds accountStatusCurrentFundsReturn : searchResults) {
165:                    assertFalse(!(accountStatusCurrentFundsReturn
166:                            .getAccountNumber().equals(
167:                                    accountStatusCurrentFunds
168:                                            .getAccountNumber())
169:                            && accountStatusCurrentFundsReturn
170:                                    .getUniversityFiscalYear().equals(
171:                                            accountStatusCurrentFunds
172:                                                    .getUniversityFiscalYear()) && accountStatusCurrentFundsReturn
173:                            .getChartOfAccountsCode().equals(
174:                                    accountStatusCurrentFunds
175:                                            .getChartOfAccountsCode())));
176:                }
177:
178:                if (searchResults != null) {
179:                    LOG.debug("Results Size:" + searchResults.size());
180:                }
181:
182:                // compare the search results with the expected and see if they match with each other
183:                assertEquals(this .currentFundsExpectedInsertion, searchResults
184:                        .size());
185:            }
186:
187:            /**
188:             * This method uses property file parameters to create insert datacurrent records for this test
189:             * 
190:             * @param accountStatusCurrentFunds
191:             * @param lookupFields
192:             * @return
193:             */
194:            private Map<String, String> buildFieldValues(
195:                    AccountStatusCurrentFunds accountStatusCurrentFunds,
196:                    List<String> lookupFields) {
197:                Map<String, String> fieldValues = new HashMap<String, String>();
198:
199:                Map<String, Object> tempFieldValues = ObjectUtil
200:                        .buildPropertyMap(accountStatusCurrentFunds,
201:                                lookupFields);
202:                for (String key : tempFieldValues.keySet()) {
203:                    fieldValues.put(key, tempFieldValues.get(key).toString());
204:                }
205:                return fieldValues;
206:            }
207:
208:            /**
209:             * This method adds property constatants for future lookups
210:             * 
211:             * @param isExtended
212:             * @return
213:             */
214:            private List<String> getLookupFields(boolean isExtended) {
215:                List<String> lookupFields = new ArrayList<String>();
216:
217:                lookupFields.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
218:                lookupFields.add(KFSPropertyConstants.ACCOUNT_NUMBER);
219:                lookupFields.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
220:
221:                return lookupFields;
222:            }
223:
224:            /**
225:             * This method will add temporary test data to the Ledger Balance table
226:             */
227:            protected void insertCurrentFundsRecords() {
228:                String messageFileName = "test/src/org/kuali/module/labor/web/testdata/message.properties";
229:                String propertiesFileName = "test/src/org/kuali/module/labor/web/testdata/accountStatusCurrentFunds.properties";
230:
231:                properties = (new TestDataGenerator(propertiesFileName,
232:                        messageFileName)).getProperties();
233:                fieldNames = properties.getProperty("fieldNames");
234:                documentFieldNames = properties.getProperty("fieldNames");
235:                deliminator = properties.getProperty("deliminator");
236:
237:                CalculatedSalaryFoundationTracker cleanup = new CalculatedSalaryFoundationTracker();
238:                ObjectUtil.populateBusinessObject(cleanup, properties,
239:                        "dataCleanup", fieldNames, deliminator);
240:                Map fieldValues = ObjectUtil.buildPropertyMap(cleanup, Arrays
241:                        .asList(StringUtils.split(fieldNames, deliminator)));
242:                businessObjectService.deleteMatching(
243:                        CalculatedSalaryFoundationTracker.class, fieldValues);
244:
245:                TestDataGenerator testDataGenerator = new TestDataGenerator(
246:                        propertiesFileName, messageFileName);
247:
248:                businessObjectService = SpringContext
249:                        .getBean(BusinessObjectService.class);
250:                persistenceService = SpringContext
251:                        .getBean(PersistenceService.class);
252:
253:                int numberOfDocuments = Integer.valueOf(properties
254:                        .getProperty("getAccountStatusCurrentFunds.numOfData"));
255:                List<LedgerBalance> inputDataList = new ArrayList<LedgerBalance>();
256:                for (int i = 1; i <= numberOfDocuments; i++) {
257:                    String propertyKey = "getAccountStatusCurrentFunds.testData"
258:                            + i;
259:                    LedgerBalance inputData = new LedgerBalance();
260:                    ObjectUtil.populateBusinessObject(inputData, properties,
261:                            propertyKey, documentFieldNames, deliminator);
262:                    inputDataList.add(inputData);
263:                }
264:                String testTarget = "getAccountStatusCurrentFunds.";
265:                this .currentFundsNumberOfTestData = Integer.valueOf(properties
266:                        .getProperty(testTarget + "numOfData"));
267:                this .currentFundsExpectedInsertion = Integer.valueOf(properties
268:                        .getProperty(testTarget + "expectedInsertion"));
269:                businessObjectService.save(inputDataList);
270:            }
271:
272:            private LaborInquiryOptionsService getInquiryOptionsService() {
273:                return SpringContext.getBean(LaborInquiryOptionsService.class);
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.