Source Code Cross Referenced for BudgetNonpersonnelCopyOverBoHelperTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » kra » web » struts » form » 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.kra.web.struts.form 
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.kra.web.struts.form;
017:
018:        import static org.kuali.test.util.KualiTestAssertionUtils.assertEquality;
019:
020:        import org.kuali.core.util.KualiDecimal;
021:        import org.kuali.core.util.KualiInteger;
022:        import org.kuali.kfs.context.KualiTestBase;
023:        import org.kuali.module.kra.budget.bo.BudgetNonpersonnel;
024:        import org.kuali.module.kra.budget.web.struts.form.BudgetNonpersonnelCopyOverBoHelper;
025:        import org.kuali.test.ConfigureContext;
026:
027:        /**
028:         * This class tests methods in BudgetNonpersonnelCopyOverBoHelper.
029:         */
030:        @ConfigureContext
031:        public class BudgetNonpersonnelCopyOverBoHelperTest extends
032:                KualiTestBase {
033:
034:            public void testBudgetNonpersonnelCopyOverBoHelper() {
035:                // BudgetNonpersonnelCopyOverBoHelper()
036:                BudgetNonpersonnelCopyOverBoHelper budgetNonpersonnel = new BudgetNonpersonnelCopyOverBoHelper();
037:                assertEquality(budgetNonpersonnel
038:                        .getBudgetNonpersonnelSequenceNumber(), new Integer(-1));
039:
040:                // //** BudgetNonpersonnelCopyOverBoHelper(BudgetNonpersonnel budgetNonpersonnel)
041:                budgetNonpersonnel = createBudgetNonpersonnelCopyOverBoHelper();
042:
043:                // indicators not changed when copyToFuturePeriods false
044:                budgetNonpersonnel.setCopyToFuturePeriods(false);
045:                budgetNonpersonnel.setAgencyCopyIndicator(false);
046:                budgetNonpersonnel
047:                        .setBudgetInstitutionCostShareCopyIndicator(false);
048:                budgetNonpersonnel
049:                        .setBudgetThirdPartyCostShareCopyIndicator(false);
050:                BudgetNonpersonnelCopyOverBoHelper newBudgetNonpersonnel1 = new BudgetNonpersonnelCopyOverBoHelper(
051:                        budgetNonpersonnel);
052:                assertFalse(newBudgetNonpersonnel1.getAgencyCopyIndicator());
053:                assertFalse(newBudgetNonpersonnel1
054:                        .getBudgetInstitutionCostShareCopyIndicator());
055:                assertFalse(newBudgetNonpersonnel1
056:                        .getBudgetThirdPartyCostShareCopyIndicator());
057:
058:                // indicators changed when copyToFuturePeriods true
059:                budgetNonpersonnel.setCopyToFuturePeriods(true);
060:                newBudgetNonpersonnel1 = new BudgetNonpersonnelCopyOverBoHelper(
061:                        budgetNonpersonnel);
062:                assertTrue(newBudgetNonpersonnel1.getAgencyCopyIndicator());
063:                assertTrue(newBudgetNonpersonnel1
064:                        .getBudgetInstitutionCostShareCopyIndicator());
065:                assertTrue(newBudgetNonpersonnel1
066:                        .getBudgetThirdPartyCostShareCopyIndicator());
067:
068:                // inflation values equal to non inflation values
069:                assertEquality(newBudgetNonpersonnel1
070:                        .getBudgetInflatedAgencyAmount(),
071:                        new KualiInteger(1000));
072:                assertEquality(newBudgetNonpersonnel1
073:                        .getBudgetInflatedInstitutionCostShareAmount(),
074:                        new KualiInteger(2000));
075:                assertEquality(newBudgetNonpersonnel1
076:                        .getBudgetInflatedThirdPartyCostShareAmount(),
077:                        new KualiInteger(3000));
078:
079:                // //** BudgetNonpersonnelCopyOverBoHelper(BudgetNonpersonnel budgetNonpersonnel, int inflationLength, KualiDecimal
080:                // budgetNonpersonnelInflationRate)
081:                budgetNonpersonnel = createBudgetNonpersonnelCopyOverBoHelper();
082:
083:                // indicators false, don't modify amounts
084:                budgetNonpersonnel.setAgencyCopyIndicator(false);
085:                budgetNonpersonnel
086:                        .setBudgetInstitutionCostShareCopyIndicator(false);
087:                budgetNonpersonnel
088:                        .setBudgetThirdPartyCostShareCopyIndicator(false);
089:                BudgetNonpersonnelCopyOverBoHelper newBudgetNonpersonnel2 = new BudgetNonpersonnelCopyOverBoHelper(
090:                        budgetNonpersonnel, 5, new KualiDecimal(10.0));
091:                assertEquality(newBudgetNonpersonnel2.getAgencyRequestAmount(),
092:                        new KualiInteger(1000));
093:                assertEquality(newBudgetNonpersonnel2
094:                        .getBudgetInstitutionCostShareAmount(),
095:                        new KualiInteger(2000));
096:                assertEquality(newBudgetNonpersonnel2
097:                        .getBudgetThirdPartyCostShareAmount(),
098:                        new KualiInteger(3000));
099:
100:                // indicators true, set amounts to 0
101:                budgetNonpersonnel.setAgencyCopyIndicator(true);
102:                budgetNonpersonnel
103:                        .setBudgetInstitutionCostShareCopyIndicator(true);
104:                budgetNonpersonnel
105:                        .setBudgetThirdPartyCostShareCopyIndicator(true);
106:                newBudgetNonpersonnel2 = new BudgetNonpersonnelCopyOverBoHelper(
107:                        budgetNonpersonnel, 5, new KualiDecimal(10.0));
108:                assertEquality(newBudgetNonpersonnel2.getAgencyRequestAmount(),
109:                        new KualiInteger(0));
110:                assertEquality(newBudgetNonpersonnel2
111:                        .getBudgetInstitutionCostShareAmount(),
112:                        new KualiInteger(0));
113:                assertEquality(newBudgetNonpersonnel2
114:                        .getBudgetThirdPartyCostShareAmount(),
115:                        new KualiInteger(0));
116:
117:                // inflation over 5 periods, 10%
118:                assertEquality(newBudgetNonpersonnel2
119:                        .getBudgetInflatedAgencyAmount(), new KualiInteger(
120:                        11274));
121:                assertEquality(newBudgetNonpersonnel2
122:                        .getBudgetInflatedInstitutionCostShareAmount(),
123:                        new KualiInteger(12884));
124:                assertEquality(newBudgetNonpersonnel2
125:                        .getBudgetInflatedThirdPartyCostShareAmount(),
126:                        new KualiInteger(14495));
127:
128:                // //** BudgetNonpersonnelCopyOverBoHelper(BudgetNonpersonnel originBudgetNonpersonnel, Integer
129:                // budgetPeriodSequenceNumberOverride, int inflationLength, KualiDecimal budgetNonpersonnelInflationRate)
130:                budgetNonpersonnel = createBudgetNonpersonnelCopyOverBoHelper();
131:
132:                // indicators not changed when copyToFuturePeriods false
133:                budgetNonpersonnel.setCopyToFuturePeriods(false);
134:                budgetNonpersonnel.setAgencyCopyIndicator(false);
135:                budgetNonpersonnel
136:                        .setBudgetInstitutionCostShareCopyIndicator(false);
137:                budgetNonpersonnel
138:                        .setBudgetThirdPartyCostShareCopyIndicator(false);
139:                BudgetNonpersonnelCopyOverBoHelper newBudgetNonpersonnel3 = new BudgetNonpersonnelCopyOverBoHelper(
140:                        budgetNonpersonnel, new Integer(11), 5,
141:                        new KualiDecimal(10.0));
142:                assertFalse(newBudgetNonpersonnel3.getAgencyCopyIndicator());
143:                assertFalse(newBudgetNonpersonnel3
144:                        .getBudgetInstitutionCostShareCopyIndicator());
145:                assertFalse(newBudgetNonpersonnel3
146:                        .getBudgetThirdPartyCostShareCopyIndicator());
147:
148:                // indicators changed when copyToFuturePeriods true
149:                budgetNonpersonnel.setCopyToFuturePeriods(true);
150:                newBudgetNonpersonnel3 = new BudgetNonpersonnelCopyOverBoHelper(
151:                        budgetNonpersonnel, new Integer(11), 5,
152:                        new KualiDecimal(10.0));
153:                assertTrue(newBudgetNonpersonnel3.getAgencyCopyIndicator());
154:                assertTrue(newBudgetNonpersonnel3
155:                        .getBudgetInstitutionCostShareCopyIndicator());
156:                assertTrue(newBudgetNonpersonnel3
157:                        .getBudgetThirdPartyCostShareCopyIndicator());
158:
159:                // budgetPeriodSequenceNumber = budgetPeriodSequenceNumberOverride
160:                assertEquality(newBudgetNonpersonnel3
161:                        .getBudgetPeriodSequenceNumber(), new Integer(11));
162:
163:                // amounts always set to 0
164:                assertEquality(newBudgetNonpersonnel3.getAgencyRequestAmount(),
165:                        new KualiInteger(0));
166:                assertEquality(newBudgetNonpersonnel3
167:                        .getBudgetInstitutionCostShareAmount(),
168:                        new KualiInteger(0));
169:                assertEquality(newBudgetNonpersonnel3
170:                        .getBudgetThirdPartyCostShareAmount(),
171:                        new KualiInteger(0));
172:
173:                // should be equal to the budgetNonpersonnelSequenceNumber
174:                assertEquality(newBudgetNonpersonnel3
175:                        .getBudgetOriginSequenceNumber(), new Integer(173));
176:
177:                // origin amounts should be equal to the amounts passed in
178:                assertEquality(newBudgetNonpersonnel3
179:                        .getBudgetOriginAgencyAmount(), new KualiInteger(1000));
180:                assertEquality(newBudgetNonpersonnel3
181:                        .getBudgetOriginInstitutionCostShareAmount(),
182:                        new KualiInteger(2000));
183:                assertEquality(newBudgetNonpersonnel3
184:                        .getBudgetOriginThirdPartyCostShareAmount(),
185:                        new KualiInteger(3000));
186:
187:                // budgetNonpersonnelSequenceNumber always null
188:                assertNull(newBudgetNonpersonnel3
189:                        .getBudgetNonpersonnelSequenceNumber());
190:
191:                // inflation over 5 periods, 10%
192:                assertEquality(newBudgetNonpersonnel3
193:                        .getBudgetInflatedAgencyAmount(),
194:                        new KualiInteger(1611));
195:                assertEquality(newBudgetNonpersonnel3
196:                        .getBudgetInflatedInstitutionCostShareAmount(),
197:                        new KualiInteger(3221));
198:                assertEquality(newBudgetNonpersonnel3
199:                        .getBudgetInflatedThirdPartyCostShareAmount(),
200:                        new KualiInteger(4832));
201:            }
202:
203:            public void testGetBudgetNonpersonnel() {
204:                BudgetNonpersonnelCopyOverBoHelper budgetNonpersonnel = createBudgetNonpersonnelCopyOverBoHelper();
205:
206:                // agencyCopyIndicator = false
207:                budgetNonpersonnel.setAgencyCopyIndicator(false);
208:                budgetNonpersonnel
209:                        .setBudgetInstitutionCostShareCopyIndicator(false);
210:                budgetNonpersonnel
211:                        .setBudgetThirdPartyCostShareCopyIndicator(false);
212:                budgetNonpersonnel.setCopyToFuturePeriods(true);
213:                BudgetNonpersonnel newBudgetNonpersonnel1 = budgetNonpersonnel
214:                        .getBudgetNonpersonnel();
215:                assertEquality(newBudgetNonpersonnel1.getAgencyRequestAmount(),
216:                        new KualiInteger(1000));
217:                assertEquality(newBudgetNonpersonnel1
218:                        .getBudgetInstitutionCostShareAmount(),
219:                        new KualiInteger(2000));
220:                assertEquality(newBudgetNonpersonnel1
221:                        .getBudgetThirdPartyCostShareAmount(),
222:                        new KualiInteger(3000));
223:                assertFalse(newBudgetNonpersonnel1.getCopyToFuturePeriods()); // should always be false per interface requirement
224:
225:                // agencyCopyIndicator = true
226:                budgetNonpersonnel.setAgencyCopyIndicator(true);
227:                budgetNonpersonnel
228:                        .setBudgetInstitutionCostShareCopyIndicator(true);
229:                budgetNonpersonnel
230:                        .setBudgetThirdPartyCostShareCopyIndicator(true);
231:                budgetNonpersonnel.setCopyToFuturePeriods(false);
232:                BudgetNonpersonnel newBudgetNonpersonnel2 = budgetNonpersonnel
233:                        .getBudgetNonpersonnel();
234:                assertEquality(newBudgetNonpersonnel2.getAgencyRequestAmount(),
235:                        new KualiInteger(4000));
236:                assertEquality(newBudgetNonpersonnel2
237:                        .getBudgetInstitutionCostShareAmount(),
238:                        new KualiInteger(5000));
239:                assertEquality(newBudgetNonpersonnel2
240:                        .getBudgetThirdPartyCostShareAmount(),
241:                        new KualiInteger(6000));
242:                assertFalse(newBudgetNonpersonnel2.getCopyToFuturePeriods()); // should always be false per interface requirement
243:
244:                // KULERA-491 bug: getBudgetNonpersonnel doesn't return object of type gBudgetNonpersonnel which confused OJB.
245:                boolean exceptionThrown = false;
246:                try {
247:                    BudgetNonpersonnelCopyOverBoHelper newBudgetNonpersonnel3 = (BudgetNonpersonnelCopyOverBoHelper) budgetNonpersonnel
248:                            .getBudgetNonpersonnel();
249:                } catch (ClassCastException e) {
250:                    exceptionThrown = true;
251:                }
252:                assertTrue(
253:                        "BudgetNonpersonnel.getBudgetNonpersonnel should not return an object of type BudgetNonpersonnelCopyOverBoHelper because "
254:                                + "that confuses OJB. It can only store BudgetNonpersonnel.",
255:                        exceptionThrown);
256:            }
257:
258:            /**
259:             * Helper to give a representation of a re-occuring BudgetNonpersonnelCopyOverBoHelper object. Note this may not be a valid
260:             * representation of how the object looks like in production. The reason for that is that it's easier to test if I fudge some of
261:             * the data (ie. inflation amounts are not actually the inflated amounts, if they are it's harder for me to tell if they are
262:             * indeed properly inflated).
263:             * 
264:             * @return
265:             */
266:            private BudgetNonpersonnelCopyOverBoHelper createBudgetNonpersonnelCopyOverBoHelper() {
267:                BudgetNonpersonnelCopyOverBoHelper budgetNonpersonnel = new BudgetNonpersonnelCopyOverBoHelper();
268:
269:                budgetNonpersonnel
270:                        .setBudgetNonpersonnelSequenceNumber(new Integer(173));
271:
272:                budgetNonpersonnel
273:                        .setAgencyRequestAmount(new KualiInteger(1000));
274:                budgetNonpersonnel
275:                        .setBudgetInstitutionCostShareAmount(new KualiInteger(
276:                                2000));
277:                budgetNonpersonnel
278:                        .setBudgetThirdPartyCostShareAmount(new KualiInteger(
279:                                3000));
280:
281:                budgetNonpersonnel
282:                        .setBudgetInflatedAgencyAmount(new KualiInteger(4000));
283:                budgetNonpersonnel
284:                        .setBudgetInflatedInstitutionCostShareAmount(new KualiInteger(
285:                                5000));
286:                budgetNonpersonnel
287:                        .setBudgetInflatedThirdPartyCostShareAmount(new KualiInteger(
288:                                6000));
289:
290:                budgetNonpersonnel
291:                        .setBudgetOriginAgencyAmount(new KualiInteger(7000));
292:                budgetNonpersonnel
293:                        .setBudgetOriginInstitutionCostShareAmount(new KualiInteger(
294:                                8000));
295:                budgetNonpersonnel
296:                        .setBudgetOriginThirdPartyCostShareAmount(new KualiInteger(
297:                                9000));
298:
299:                budgetNonpersonnel.setAgencyCopyIndicator(false);
300:                budgetNonpersonnel
301:                        .setBudgetInstitutionCostShareCopyIndicator(false);
302:                budgetNonpersonnel
303:                        .setBudgetThirdPartyCostShareCopyIndicator(false);
304:
305:                budgetNonpersonnel.setCopyToFuturePeriods(true);
306:
307:                return budgetNonpersonnel;
308:            }
309:        }
w_w_w___.__j_a__va2_s_._co__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.