Source Code Cross Referenced for MandatoryTransferEliminationCodeServiceTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » chart » 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.module.chart.service 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-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.chart.service;
017:
018:        import org.kuali.kfs.context.KualiTestBase;
019:        import org.kuali.kfs.context.SpringContext;
020:        import org.kuali.kfs.service.KualiCodeService;
021:        import org.kuali.module.chart.bo.codes.MandatoryTransferEliminationCode;
022:        import org.kuali.test.ConfigureContext;
023:        import org.kuali.test.suite.AnnotationTestSuite;
024:        import org.kuali.test.suite.CrossSectionSuite;
025:
026:        /**
027:         * This class tests the MandatoryTransferEliminationCode service.
028:         */
029:        @AnnotationTestSuite(CrossSectionSuite.class)
030:        @ConfigureContext
031:        public class MandatoryTransferEliminationCodeServiceTest extends
032:                KualiTestBase {
033:
034:            private static final String GOOD_CODE = "N";
035:            private static final String GOOD_NAME = "NEITHER";
036:            private static final String NONEXISTENT_CODE = "A"; // This code is not in the database. Please do not add it, or you will break
037:            // this test.
038:            private static final String NONEXISTENT_NAME = "BAD";
039:
040:            /**
041:             * @see org.kuali.test.KualiTestBase#setUp()
042:             */
043:            @Override
044:            protected void setUp() throws Exception {
045:                super .setUp();
046:                validateTestFixtures();
047:            }
048:
049:            /**
050:             * Performs miscellaneous tests for this service.
051:             */
052:            public void testByCode_valid_name() {
053:                // test known-good byCode
054:                MandatoryTransferEliminationCode mtec = (MandatoryTransferEliminationCode) SpringContext
055:                        .getBean(KualiCodeService.class).getByCode(
056:                                MandatoryTransferEliminationCode.class,
057:                                GOOD_CODE);
058:                assertEquals(
059:                        "Known-good code results in expected returned Name.",
060:                        GOOD_NAME, mtec.getName());
061:            }
062:
063:            public void testByName_valid_name() {
064:                // test known-good byName
065:                MandatoryTransferEliminationCode mtec = (MandatoryTransferEliminationCode) SpringContext
066:                        .getBean(KualiCodeService.class).getByName(
067:                                MandatoryTransferEliminationCode.class,
068:                                GOOD_NAME);
069:                assertEquals(
070:                        "Known-good name results in expected returned code.",
071:                        GOOD_CODE, mtec.getCode());
072:            }
073:
074:            public void stestByCode_invalid_name() {
075:                // test known-bad byCode
076:                MandatoryTransferEliminationCode mtec = (MandatoryTransferEliminationCode) SpringContext
077:                        .getBean(KualiCodeService.class).getByCode(
078:                                MandatoryTransferEliminationCode.class,
079:                                NONEXISTENT_CODE);
080:                assertNull("Known-bad code returns null object.", mtec);
081:            }
082:
083:            public void testByName_invalid_name() {
084:                // test known-bad byName
085:                MandatoryTransferEliminationCode mtec = (MandatoryTransferEliminationCode) SpringContext
086:                        .getBean(KualiCodeService.class).getByName(
087:                                MandatoryTransferEliminationCode.class,
088:                                NONEXISTENT_NAME);
089:                assertNull("Known-bad code returns null object.", mtec);
090:            }
091:
092:            public void testByCode_empty() {
093:                // test known-bad byCode
094:                MandatoryTransferEliminationCode mtec = (MandatoryTransferEliminationCode) SpringContext
095:                        .getBean(KualiCodeService.class).getByCode(
096:                                MandatoryTransferEliminationCode.class, "");
097:                assertNull("Known-empty code returns null object.", mtec);
098:            }
099:
100:            public void testByCode_null() {
101:                // test known-bad byCode
102:                MandatoryTransferEliminationCode mtec = (MandatoryTransferEliminationCode) SpringContext
103:                        .getBean(KualiCodeService.class).getByCode(
104:                                MandatoryTransferEliminationCode.class, null);
105:                assertNull("Known-null code returns null object.", mtec);
106:            }
107:
108:            public void testSave() {
109:                String oldName;
110:                String newName;
111:
112:                // get the existing value
113:                MandatoryTransferEliminationCode mtec = (MandatoryTransferEliminationCode) SpringContext
114:                        .getBean(KualiCodeService.class).getByCode(
115:                                MandatoryTransferEliminationCode.class,
116:                                GOOD_CODE);
117:
118:                // cache the old value, create a new value, and modify the object
119:                oldName = mtec.getName();
120:                newName = oldName + "2";
121:                mtec.setName(newName);
122:
123:                // attempt to save the modified object
124:                SpringContext.getBean(KualiCodeService.class).save(mtec);
125:
126:                // open the object byCode() and confirm that the changes were saved
127:                mtec = null;
128:                mtec = (MandatoryTransferEliminationCode) SpringContext
129:                        .getBean(KualiCodeService.class).getByCode(
130:                                MandatoryTransferEliminationCode.class,
131:                                GOOD_CODE);
132:                assertEquals(
133:                        "Changes to the document were not persisted to the database.",
134:                        newName, mtec.getName());
135:
136:                // revert back to the old name if it worked
137:                mtec.setName(oldName);
138:                SpringContext.getBean(KualiCodeService.class).save(mtec);
139:
140:                mtec = null;
141:                mtec = (MandatoryTransferEliminationCode) SpringContext
142:                        .getBean(KualiCodeService.class).getByCode(
143:                                MandatoryTransferEliminationCode.class,
144:                                GOOD_CODE);
145:                assertEquals(
146:                        "Changes to the document were not persisted to the database.",
147:                        oldName, mtec.getName());
148:            }
149:
150:            public void testActive() {
151:
152:                // test known-good active code
153:                MandatoryTransferEliminationCode mtec = (MandatoryTransferEliminationCode) SpringContext
154:                        .getBean(KualiCodeService.class).getByCode(
155:                                MandatoryTransferEliminationCode.class,
156:                                GOOD_CODE);
157:                assertEquals(
158:                        "The active code associated with this field is incorrect",
159:                        true, mtec.isActive());
160:
161:            }
162:
163:            private void validateTestFixtures() {
164:                MandatoryTransferEliminationCode code = (MandatoryTransferEliminationCode) SpringContext
165:                        .getBean(KualiCodeService.class).getByCode(
166:                                MandatoryTransferEliminationCode.class,
167:                                GOOD_CODE);
168:                assertEquals(GOOD_CODE, code.getCode());
169:                assertEquals(GOOD_NAME, code.getName());
170:
171:                code = (MandatoryTransferEliminationCode) SpringContext
172:                        .getBean(KualiCodeService.class).getByName(
173:                                MandatoryTransferEliminationCode.class,
174:                                GOOD_NAME);
175:                assertEquals(GOOD_CODE, code.getCode());
176:                assertEquals(GOOD_NAME, code.getName());
177:
178:                code = (MandatoryTransferEliminationCode) SpringContext
179:                        .getBean(KualiCodeService.class).getByCode(
180:                                MandatoryTransferEliminationCode.class,
181:                                NONEXISTENT_CODE);
182:                assertNull(code);
183:                code = (MandatoryTransferEliminationCode) SpringContext
184:                        .getBean(KualiCodeService.class).getByName(
185:                                MandatoryTransferEliminationCode.class,
186:                                NONEXISTENT_CODE);
187:                assertNull(code);
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.