Source Code Cross Referenced for BatchInputServiceSystemParametersTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » kfs » 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.kfs.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.kfs.service;
017:
018:        import java.util.List;
019:
020:        import org.apache.commons.lang.StringUtils;
021:        import org.kuali.core.bo.user.UniversalUser;
022:        import org.kuali.core.service.UniversalUserService;
023:        import org.kuali.kfs.KFSConstants;
024:        import org.kuali.kfs.KFSConstants.SystemGroupParameterNames;
025:        import org.kuali.kfs.batch.BatchInputFileType;
026:        import org.kuali.kfs.context.KualiTestBase;
027:        import org.kuali.kfs.context.SpringContext;
028:        import org.kuali.kfs.context.TestUtils;
029:        import org.kuali.kfs.service.impl.ParameterConstants;
030:        import org.kuali.module.financial.batch.pcard.ProcurementCardInputFileType;
031:        import org.kuali.module.gl.batch.collector.CollectorInputFileType;
032:        import org.kuali.test.ConfigureContext;
033:        import org.kuali.test.KualiTestConstants.TestConstants.Data4;
034:
035:        /**
036:         * Tests system parameters are setup and methods on the batch input types are correctly using them.
037:         */
038:        @ConfigureContext
039:        public class BatchInputServiceSystemParametersTest extends
040:                KualiTestBase {
041:            private ParameterService parameterService;
042:            private BatchInputFileService batchInputFileService;
043:
044:            private BatchInputFileType pcdoBatchInputFileType;
045:            private BatchInputFileType collectorBatchInputFileType;
046:
047:            private UniversalUser validWorkgroupUser;
048:            private UniversalUser invalidWorkgroupUser;
049:
050:            /**
051:             * @see junit.framework.TestCase#setUp()
052:             */
053:            @Override
054:            protected void setUp() throws Exception {
055:                super .setUp();
056:
057:                parameterService = SpringContext
058:                        .getBean(ParameterService.class);
059:                batchInputFileService = SpringContext
060:                        .getBean(BatchInputFileService.class);
061:                pcdoBatchInputFileType = SpringContext
062:                        .getBean(ProcurementCardInputFileType.class);
063:                collectorBatchInputFileType = SpringContext
064:                        .getBean(CollectorInputFileType.class);
065:
066:                validWorkgroupUser = SpringContext.getBean(
067:                        UniversalUserService.class)
068:                        .getUniversalUserByAuthenticationUserId(Data4.USER_ID2);
069:                invalidWorkgroupUser = SpringContext.getBean(
070:                        UniversalUserService.class)
071:                        .getUniversalUserByAuthenticationUserId(Data4.USER_ID1);
072:            }
073:
074:            /**
075:             * Verifies system parameters needed by the batch upload process exist in the db.
076:             */
077:            public final void testSystemParametersExist() throws Exception {
078:                List<String> activeFileTypes = parameterService
079:                        .getParameterValues(
080:                                ParameterConstants.FINANCIAL_SYSTEM_BATCH.class,
081:                                SystemGroupParameterNames.ACTIVE_INPUT_TYPES_PARAMETER_NAME);
082:                assertTrue(
083:                        "system parameter "
084:                                + SystemGroupParameterNames.ACTIVE_INPUT_TYPES_PARAMETER_NAME
085:                                + " is not setup or contains no file types",
086:                        activeFileTypes != null
087:                                && activeFileTypes.size() > 0
088:                                && StringUtils.isNotBlank(activeFileTypes
089:                                        .get(0)));
090:
091:                String pcdoUploadWorkgroup = parameterService
092:                        .getParameterValue(
093:                                pcdoBatchInputFileType
094:                                        .getUploadWorkgroupParameterComponent(),
095:                                KFSConstants.SystemGroupParameterNames.FILE_TYPE_WORKGROUP_PARAMETER_NAME);
096:                assertTrue(
097:                        "system parameter pcdo "
098:                                + KFSConstants.SystemGroupParameterNames.FILE_TYPE_WORKGROUP_PARAMETER_NAME
099:                                + " does not exist or has empty value.",
100:                        StringUtils.isNotBlank(pcdoUploadWorkgroup));
101:
102:                String collectorUploadWorkgroup = parameterService
103:                        .getParameterValue(
104:                                collectorBatchInputFileType
105:                                        .getUploadWorkgroupParameterComponent(),
106:                                KFSConstants.SystemGroupParameterNames.FILE_TYPE_WORKGROUP_PARAMETER_NAME);
107:                assertTrue(
108:                        "system parameter collector "
109:                                + KFSConstants.SystemGroupParameterNames.FILE_TYPE_WORKGROUP_PARAMETER_NAME
110:                                + " does not exist or has empty value.",
111:                        StringUtils.isNotBlank(pcdoUploadWorkgroup));
112:            }
113:
114:            /**
115:             * Set SystemGroupParameterNames.ACTIVE_INPUT_TYPES_PARAMETER_NAME to empty and verify both pcdo & collector are inactive
116:             */
117:            public final void testIsBatchInputTypeActive_emptySystemParameter()
118:                    throws Exception {
119:                setActiveSystemParameter("", true);
120:                assertFalse(
121:                        "pcdo isActive method not false when active param is empty",
122:                        batchInputFileService
123:                                .isBatchInputTypeActive(pcdoBatchInputFileType));
124:                assertFalse(
125:                        "collector isActive method not false when active param is empty",
126:                        batchInputFileService
127:                                .isBatchInputTypeActive(collectorBatchInputFileType));
128:            }
129:
130:            /**
131:             * Set SystemGroupParameterNames.ACTIVE_INPUT_TYPES_PARAMETER_NAME to an invalid group and verify both pcdo & collector are
132:             * inactive
133:             */
134:            public final void testIsBatchInputTypeActive_invalidSystemParameter()
135:                    throws Exception {
136:                setActiveSystemParameter("foo", true);
137:                assertFalse(
138:                        "pcdo isActive method not false when active param is foo",
139:                        batchInputFileService
140:                                .isBatchInputTypeActive(pcdoBatchInputFileType));
141:                assertFalse(
142:                        "collector isActive method not false when active param is foo",
143:                        batchInputFileService
144:                                .isBatchInputTypeActive(collectorBatchInputFileType));
145:            }
146:
147:            /**
148:             * Set SystemGroupParameterNames.ACTIVE_INPUT_TYPES_PARAMETER_NAME to contain both indentifiers and verify both pcdo & collector
149:             * are active
150:             */
151:            public final void testIsBatchInputTypeActive_systemParameterContainsBoth()
152:                    throws Exception {
153:                setActiveSystemParameter(collectorBatchInputFileType
154:                        .getFileTypeIdentifer()
155:                        + ";" + pcdoBatchInputFileType.getFileTypeIdentifer(),
156:                        true);
157:                assertTrue(
158:                        "pcdo isActive method not true when active param contains identifier",
159:                        batchInputFileService
160:                                .isBatchInputTypeActive(pcdoBatchInputFileType));
161:                assertTrue(
162:                        "collector isActive method not true when active param contains identifier",
163:                        batchInputFileService
164:                                .isBatchInputTypeActive(collectorBatchInputFileType));
165:            }
166:
167:            /**
168:             * Set SystemGroupParameterNames.ACTIVE_INPUT_TYPES_PARAMETER_NAME to contain one indentifier and verify the correct one is
169:             * active and other type is inactive.
170:             */
171:            public final void testIsBatchInputTypeActive_systemParameterContainsOne()
172:                    throws Exception {
173:                setActiveSystemParameter(collectorBatchInputFileType
174:                        .getFileTypeIdentifer(), true);
175:                assertFalse(
176:                        "pcdo isActive method is true when active param does not contain identifier",
177:                        batchInputFileService
178:                                .isBatchInputTypeActive(pcdoBatchInputFileType));
179:                assertTrue(
180:                        "collector isActive method not true when active param contains identifier",
181:                        batchInputFileService
182:                                .isBatchInputTypeActive(collectorBatchInputFileType));
183:
184:                setActiveSystemParameter(pcdoBatchInputFileType
185:                        .getFileTypeIdentifer(), true);
186:                assertTrue(
187:                        "pcdo isActive method is false when active param contains identifier",
188:                        batchInputFileService
189:                                .isBatchInputTypeActive(pcdoBatchInputFileType));
190:                assertFalse(
191:                        "collector isActive method is true when active param does not contain identifier",
192:                        batchInputFileService
193:                                .isBatchInputTypeActive(collectorBatchInputFileType));
194:            }
195:
196:            /**
197:             * Changes the text for the batch input active system parameter, stores and clears cache.
198:             */
199:            private final void setActiveSystemParameter(String parameterText,
200:                    boolean multiValue) throws Exception {
201:                TestUtils
202:                        .setSystemParameter(
203:                                ParameterConstants.FINANCIAL_SYSTEM_BATCH.class,
204:                                SystemGroupParameterNames.ACTIVE_INPUT_TYPES_PARAMETER_NAME,
205:                                parameterText);
206:            }
207:
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.