Source Code Cross Referenced for BudgetNonpersonnelCopyOverFormHelperTest.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 java.util.List;
021:
022:        import org.kuali.core.util.KualiDecimal;
023:        import org.kuali.kfs.context.KualiTestBase;
024:        import org.kuali.kfs.context.SpringContext;
025:        import org.kuali.module.kra.bo.BudgetNonpersonnelTest;
026:        import org.kuali.module.kra.bo.BudgetPeriodTest;
027:        import org.kuali.module.kra.budget.bo.BudgetNonpersonnel;
028:        import org.kuali.module.kra.budget.service.BudgetNonpersonnelService;
029:        import org.kuali.module.kra.budget.web.struts.form.BudgetForm;
030:        import org.kuali.module.kra.budget.web.struts.form.BudgetNonpersonnelCopyOverFormHelper;
031:        import org.kuali.module.kra.budget.web.struts.form.BudgetNonpersonnelCopyOverFormHelper.NonpersonnelCopyOverCategoryHelper;
032:        import org.kuali.test.ConfigureContext;
033:
034:        /**
035:         * This class tests methods in BudgetNonpersonnelCopyOverFormHelper.
036:         */
037:        @ConfigureContext
038:        public class BudgetNonpersonnelCopyOverFormHelperTest extends
039:                KualiTestBase {
040:
041:            private BudgetForm budgetForm;
042:
043:            @Override
044:            protected void setUp() throws Exception {
045:                super .setUp();
046:                budgetForm = new BudgetForm();
047:
048:                budgetForm.setNonpersonnelCategories(SpringContext.getBean(
049:                        BudgetNonpersonnelService.class)
050:                        .getAllNonpersonnelCategories());
051:
052:                String[] categories = { "CO", "CO", "FL" };
053:                String[] subCategories = { "C1", "C1", "F5" };
054:                String[] subcontractorNumber = { "", "", "" };
055:                budgetForm.getBudgetDocument().getBudget()
056:                        .setNonpersonnelItems(
057:                                BudgetNonpersonnelTest
058:                                        .createBudgetNonpersonnel(categories,
059:                                                subCategories,
060:                                                subcontractorNumber));
061:                budgetForm.setCurrentTaskNumber(new Integer(0));
062:                budgetForm.getBudgetDocument().getBudget().setPeriods(
063:                        BudgetPeriodTest.createBudgetPeriods(5));
064:                budgetForm.getBudgetDocument().getBudget()
065:                        .setBudgetNonpersonnelInflationRate(
066:                                new KualiDecimal(10));
067:            }
068:
069:            public void testBudgetNonpersonnelCopyOverFormHelper() {
070:                BudgetNonpersonnelCopyOverFormHelper budgetNonpersonnelCopyOverFormHelper1 = new BudgetNonpersonnelCopyOverFormHelper();
071:                assertTrue(
072:                        "should have empty nonpersonnelCopyOverCategoryHelpers so that hidden variables can populate it",
073:                        budgetNonpersonnelCopyOverFormHelper1
074:                                .getNonpersonnelCopyOverCategoryHelpers()
075:                                .isEmpty());
076:
077:                BudgetNonpersonnelCopyOverFormHelper budgetNonpersonnelCopyOverFormHelper2 = new BudgetNonpersonnelCopyOverFormHelper(
078:                        budgetForm);
079:
080:                assertNotNull("Should not be null after construction.",
081:                        budgetNonpersonnelCopyOverFormHelper2);
082:                assertNotNull("Should not be null after construction.",
083:                        budgetNonpersonnelCopyOverFormHelper2
084:                                .getNonpersonnelCopyOverCategoryHelpers());
085:                // Further tests are easier done after decontruction. The important part here is that it doesn't crash.
086:            }
087:
088:            public void testDeconstruct() {
089:                BudgetNonpersonnel budgetNonpersonnel = (BudgetNonpersonnel) budgetForm
090:                        .getBudgetDocument().getBudget().getNonpersonnelItem(0);
091:                budgetNonpersonnel.setCopyToFuturePeriods(true);
092:                budgetNonpersonnel = (BudgetNonpersonnel) budgetForm
093:                        .getBudgetDocument().getBudget().getNonpersonnelItem(2);
094:                budgetNonpersonnel.setCopyToFuturePeriods(true);
095:
096:                BudgetNonpersonnelCopyOverFormHelper budgetNonpersonnelCopyOverFormHelper1 = new BudgetNonpersonnelCopyOverFormHelper(
097:                        budgetForm);
098:                budgetNonpersonnelCopyOverFormHelper1.deconstruct(budgetForm);
099:
100:                List budgetNonpersonnelList = budgetForm.getBudgetDocument()
101:                        .getBudget().getNonpersonnelItems();
102:                assertTrue("Incorrect number of items found after copy over.",
103:                        budgetNonpersonnelList.size() == 11);
104:
105:                // Could test values next for a more exhaustive test case, but this covers the basics for now.
106:            }
107:
108:            public void testRefresh() {
109:                this .testDeconstruct(); // this will leave budgetForm with interesting data to refresh.
110:
111:                BudgetNonpersonnelCopyOverFormHelper budgetNonpersonnelCopyOverFormHelper1 = new BudgetNonpersonnelCopyOverFormHelper(
112:                        budgetForm);
113:
114:                // note that BudgetNonpersonnelCopyOverFormHelper constructor already calls refresh, so calling it again is kind of mute,
115:                // but it shouldn't hurt either. For any chance: We're interested in testing the totals.
116:                budgetNonpersonnelCopyOverFormHelper1.refresh(budgetForm
117:                        .getBudgetDocument().getBudget().getPeriods().size());
118:
119:                NonpersonnelCopyOverCategoryHelper nonpersonnelCopyOverCategoryHelper = (NonpersonnelCopyOverCategoryHelper) budgetNonpersonnelCopyOverFormHelper1
120:                        .getNonpersonnelCopyOverCategoryHelpers().get("CO");
121:
122:                assertEquality(new KualiDecimal(2000),
123:                        nonpersonnelCopyOverCategoryHelper
124:                                .getAgencyRequestAmountTotal().get(0));
125:                assertEquality(new KualiDecimal(1100),
126:                        nonpersonnelCopyOverCategoryHelper
127:                                .getAgencyRequestAmountTotal().get(1));
128:                assertEquality(new KualiDecimal(1210),
129:                        nonpersonnelCopyOverCategoryHelper
130:                                .getAgencyRequestAmountTotal().get(2));
131:                assertEquality(new KualiDecimal(1331),
132:                        nonpersonnelCopyOverCategoryHelper
133:                                .getAgencyRequestAmountTotal().get(3));
134:                assertEquality(new KualiDecimal(1464),
135:                        nonpersonnelCopyOverCategoryHelper
136:                                .getAgencyRequestAmountTotal().get(4));
137:
138:                assertEquality(new KualiDecimal(4000),
139:                        nonpersonnelCopyOverCategoryHelper
140:                                .getBudgetInstitutionCostShareAmountTotal()
141:                                .get(0));
142:                assertEquality(new KualiDecimal(2200),
143:                        nonpersonnelCopyOverCategoryHelper
144:                                .getBudgetInstitutionCostShareAmountTotal()
145:                                .get(1));
146:                assertEquality(new KualiDecimal(2420),
147:                        nonpersonnelCopyOverCategoryHelper
148:                                .getBudgetInstitutionCostShareAmountTotal()
149:                                .get(2));
150:                assertEquality(new KualiDecimal(2662),
151:                        nonpersonnelCopyOverCategoryHelper
152:                                .getBudgetInstitutionCostShareAmountTotal()
153:                                .get(3));
154:                assertEquality(new KualiDecimal(2928),
155:                        nonpersonnelCopyOverCategoryHelper
156:                                .getBudgetInstitutionCostShareAmountTotal()
157:                                .get(4));
158:
159:                assertEquality(new KualiDecimal(6000),
160:                        nonpersonnelCopyOverCategoryHelper
161:                                .getBudgetThirdPartyCostShareAmountTotal().get(
162:                                        0));
163:                assertEquality(new KualiDecimal(3300),
164:                        nonpersonnelCopyOverCategoryHelper
165:                                .getBudgetThirdPartyCostShareAmountTotal().get(
166:                                        1));
167:                assertEquality(new KualiDecimal(3630),
168:                        nonpersonnelCopyOverCategoryHelper
169:                                .getBudgetThirdPartyCostShareAmountTotal().get(
170:                                        2));
171:                assertEquality(new KualiDecimal(3993),
172:                        nonpersonnelCopyOverCategoryHelper
173:                                .getBudgetThirdPartyCostShareAmountTotal().get(
174:                                        3));
175:                assertEquality(new KualiDecimal(4392),
176:                        nonpersonnelCopyOverCategoryHelper
177:                                .getBudgetThirdPartyCostShareAmountTotal().get(
178:                                        4));
179:            }
180:        }
w__ww___.___j___a__v_a___2_s.c__om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.