Source Code Cross Referenced for LedgerBalanceLookupableHelperServiceTest.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.HashMap;
020:        import java.util.List;
021:        import java.util.Map;
022:        import java.util.Properties;
023:
024:        import org.kuali.core.lookup.LookupableHelperService;
025:        import org.kuali.core.service.BusinessObjectService;
026:        import org.kuali.core.service.PersistenceService;
027:        import org.kuali.kfs.KFSPropertyConstants;
028:        import org.kuali.kfs.context.KualiTestBase;
029:        import org.kuali.kfs.context.SpringContext;
030:        import org.kuali.kfs.lookup.LookupableSpringContext;
031:        import org.kuali.module.gl.web.TestDataGenerator;
032:        import org.kuali.module.labor.bo.LedgerBalance;
033:        import org.kuali.module.labor.util.ObjectUtil;
034:        import org.kuali.test.ConfigureContext;
035:
036:        /**
037:         * This class contains the test cases that can be applied to the method in LedgerBalanceLookupableImpl class.
038:         */
039:        @ConfigureContext
040:        public class LedgerBalanceLookupableHelperServiceTest extends
041:                KualiTestBase {
042:            private BusinessObjectService businessObjectService;
043:            private LookupableHelperService lookupableHelperService;
044:            private PersistenceService persistenceService;
045:
046:            private Properties properties;
047:            private String fieldNames, documentFieldNames;
048:            private String deliminator;
049:            private int ledgerBalanceNumberOfTestData;
050:            private int ledgerBalanceExpectedInsertion;
051:
052:            @Override
053:            protected void setUp() throws Exception {
054:                super .setUp();
055:
056:                businessObjectService = SpringContext
057:                        .getBean(BusinessObjectService.class);
058:
059:                lookupableHelperService = LookupableSpringContext
060:                        .getLookupableHelperService("laborLedgerBalanceLookupableHelperService");
061:                lookupableHelperService
062:                        .setBusinessObjectClass(LedgerBalance.class);
063:
064:                // Clear up the database so that any existing data cannot affact your test result
065:                HashMap keys = new HashMap();
066:                keys.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, "2004");
067:                keys.put(KFSPropertyConstants.EMPLID, "1000000005");
068:                keys
069:                        .put(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
070:                                "AC");
071:                keys.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, "BL");
072:                businessObjectService.deleteMatching(LedgerBalance.class, keys);
073:            }
074:
075:            public void testGetSearchResults() throws Exception {
076:                insertLedgerBalanceRecords();
077:
078:                LedgerBalance ledgerBalance = new LedgerBalance();
079:                ledgerBalance.setUniversityFiscalYear(2004);
080:                ledgerBalance.setEmplid("0000001265");
081:                ledgerBalance.setBalanceTypeCode("AC");
082:                ledgerBalance.setChartOfAccountsCode("BL");
083:
084:                // test the search results before the specified entry is inserted into the database
085:                Map fieldValues = buildFieldValues(ledgerBalance, this 
086:                        .getLookupFields(false));
087:                List searchResults = lookupableHelperService
088:                        .getSearchResults(fieldValues);
089:
090:                if (searchResults != null) {
091:                    System.out.println("Results Size:" + searchResults.size());
092:                }
093:
094:                // compare the search results with the expected and see if they match with each other
095:                assertEquals(this .ledgerBalanceExpectedInsertion, searchResults
096:                        .size());
097:            }
098:
099:            private Map<String, String> buildFieldValues(
100:                    LedgerBalance ledgerBalance, List<String> lookupFields) {
101:                Map<String, String> fieldValues = new HashMap<String, String>();
102:
103:                Map<String, Object> tempFieldValues = ObjectUtil
104:                        .buildPropertyMap(ledgerBalance, lookupFields);
105:                for (String key : tempFieldValues.keySet()) {
106:                    fieldValues.put(key, tempFieldValues.get(key).toString());
107:                }
108:                return fieldValues;
109:            }
110:
111:            private List<String> getLookupFields(boolean isExtended) {
112:                List<String> lookupFields = new ArrayList<String>();
113:
114:                lookupFields.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
115:                lookupFields.add(KFSPropertyConstants.EMPLID);
116:                lookupFields
117:                        .add(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE);
118:                lookupFields.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
119:
120:                return lookupFields;
121:            }
122:
123:            protected void insertLedgerBalanceRecords() {
124:                String messageFileName = "test/src/org/kuali/module/labor/web/testdata/message.properties";
125:                String propertiesFileName = "test/src/org/kuali/module/labor/web/testdata/ledgerBalance.properties";
126:
127:                properties = (new TestDataGenerator(propertiesFileName,
128:                        messageFileName)).getProperties();
129:                fieldNames = properties.getProperty("fieldNames");
130:                documentFieldNames = properties.getProperty("fieldNames");
131:                deliminator = properties.getProperty("deliminator");
132:
133:                TestDataGenerator testDataGenerator = new TestDataGenerator(
134:                        propertiesFileName, messageFileName);
135:
136:                businessObjectService = SpringContext
137:                        .getBean(BusinessObjectService.class);
138:                persistenceService = SpringContext
139:                        .getBean(PersistenceService.class);
140:
141:                int numberOfDocuments = Integer.valueOf(properties
142:                        .getProperty("getLedgerBalance.numOfData"));
143:                List<LedgerBalance> inputDataList = new ArrayList<LedgerBalance>();
144:                for (int i = 1; i <= numberOfDocuments; i++) {
145:                    String propertyKey = "getLedgerBalance.testData" + i;
146:                    LedgerBalance inputData = new LedgerBalance();
147:                    ObjectUtil.populateBusinessObject(inputData, properties,
148:                            propertyKey, documentFieldNames, deliminator);
149:                    inputDataList.add(inputData);
150:                }
151:
152:                String testTarget = "getLedgerBalance.";
153:                this .ledgerBalanceNumberOfTestData = Integer.valueOf(properties
154:                        .getProperty(testTarget + "numOfData"));
155:                this .ledgerBalanceExpectedInsertion = Integer
156:                        .valueOf(properties.getProperty(testTarget
157:                                + "expectedInsertion"));
158:                businessObjectService.save(inputDataList);
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.