Source Code Cross Referenced for TestReviewerElement.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » services » docelements » 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 » edu.iu.uis.eden.services.docelements 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package edu.iu.uis.eden.services.docelements;
002:
003:        import org.jdom.Element;
004:
005:        import edu.iu.uis.eden.WorkflowServiceErrorImpl;
006:        import edu.iu.uis.eden.exception.InvalidXmlException;
007:        import edu.iu.uis.eden.services.IDocElement;
008:        import edu.iu.uis.eden.services.InconsistentDocElementStateException;
009:        import edu.iu.uis.eden.services.ServiceErrorConstants;
010:
011:        public class TestReviewerElement extends IDocInterfaceTestTemplate {
012:            private ReviewerElement reviewer;
013:            private String networkId = "rkirkend";
014:            private String partyType = "U";
015:
016:            public TestReviewerElement(String s) {
017:                super (s);
018:            }
019:
020:            protected void setUp() {
021:                reviewer = new ReviewerElement();
022:            }
023:
024:            protected void tearDown() {
025:            }
026:
027:            /**
028:             * for use with super class
029:             *
030:             * @return the IDocElement for this test
031:             */
032:            public IDocElement getIDocElement() {
033:                return reviewer;
034:            }
035:
036:            /**
037:             * makes some valid xml and see if it loads up correctly.
038:             * super class will check for standard behavior in case of
039:             * invalid element
040:             */
041:            public void testLoadFromXMLContent() {
042:                Element me = new Element(reviewer.getElementName());
043:
044:                //put this guy in without children without allowing blanks
045:                try {
046:                    reviewer.loadFromXMLContent(me, false);
047:                    fail("didn't throw InconsistentDocElementStateException when "
048:                            + "loadFromXMLContent given a root Element with no children "
049:                            + "and allowBlank set to false");
050:                } catch (InvalidXmlException ex) {
051:                    fail("didn't throw InconsistentDocElementStateException when "
052:                            + "loadFromXMLContent given a root Element with no children "
053:                            + "and allowBlank set to false");
054:                } catch (InconsistentDocElementStateException ex) {
055:                }
056:
057:                //load w/ just one element and allow blanks
058:                NetworkIdElement networkId = new NetworkIdElement();
059:                networkId.setNetworkId("rkirkend");
060:                me.addContent(networkId.getXMLContent());
061:
062:                try {
063:                    reviewer.loadFromXMLContent(me, true);
064:                    assertEquals(
065:                            "didn't properly load props from valid element",
066:                            networkId.getNetworkId(), reviewer.getNetworkId());
067:                } catch (Exception ex) {
068:                    fail("threw exception loading valid element with one child "
069:                            + "missing and allowBlank set true");
070:                }
071:
072:                //load both and check props
073:                PartyTypeElement partyType = new PartyTypeElement();
074:                partyType.setPartyType("U");
075:                me.addContent(partyType.getXMLContent());
076:
077:                try {
078:                    reviewer.loadFromXMLContent(me, false);
079:                    assertEquals("didn't correctly load props from valid xml",
080:                            partyType.getPartyType(), reviewer.getPartyType());
081:                } catch (Exception ex) {
082:                    fail("threw exception loading valid element");
083:                }
084:            }
085:
086:            /**
087:             * test varying states of the object against the element they should
088:             * make
089:             */
090:            public void testGetXMLContent() {
091:                super .testGetXMLContent();
092:
093:                //set a prop so reviewer won't be empty and we can see if it's
094:                //bringing back the correct tag.
095:                reviewer.setNetworkId("rkirkend");
096:
097:                Element me = reviewer.getXMLContent();
098:                assertEquals(
099:                        "didn't properly make xml element name is incorrect",
100:                        reviewer.getElementName(), me.getName());
101:
102:                //check that a child element is present
103:                assertNotNull("didn't represent member IDocElements in xml", me
104:                        .getChild("networkid"));
105:            }
106:
107:            /**
108:             *  shouldnt be valid when empty should be valid with one prop set
109:             */
110:            public void testValidate() {
111:                try {
112:                    WorkflowServiceErrorImpl errors = reviewer.validate();
113:                    assertNotNull("Empty reviewer returned null on validate",
114:                            errors);
115:
116:                    assertEquals(
117:                            "ReviewerElement didn't set correct errorType",
118:                            errors.getKey(),
119:                            ServiceErrorConstants.CHILDREN_IN_ERROR);
120:
121:                    //set jus a prop should return a doc element error
122:                    reviewer.setNetworkId("rkirkend");
123:                    assertNotNull(
124:                            "Reviewer with just networkId set returned null on validate",
125:                            errors);
126:
127:                    assertEquals(
128:                            "ReviewerElement didn't set correct errorType",
129:                            errors.getKey(),
130:                            ServiceErrorConstants.CHILDREN_IN_ERROR);
131:
132:                    //set just partyType test same thing
133:                    reviewer.setNetworkId(null);
134:                    reviewer.setPartyType("U");
135:
136:                    assertNotNull(
137:                            "Reviewer with just partType set returned null on validate",
138:                            errors);
139:
140:                    assertEquals(
141:                            "ReviewerElement didn't set correct errorType",
142:                            errors.getKey(),
143:                            ServiceErrorConstants.CHILDREN_IN_ERROR);
144:
145:                    //set both and they should be good
146:                    reviewer.setNetworkId("rkirkend");
147:                    reviewer.setPartyType("U");
148:                    assertNull("Valid reviewer didn't return null", reviewer
149:                            .validate());
150:                } catch (Exception ex) {
151:                    fail("threw exception validating");
152:                }
153:            }
154:
155:            /**
156:             * test that responsibilityId is being correctly set internally
157:             */
158:            public void testSetResponsibilityId() {
159:                /* set the partyType and responsibilityId should be null */
160:                this .reviewer.setPartyType("U");
161:                assertNull(
162:                        "ResponsibilityId is being set when only partyType is set",
163:                        this .reviewer.getResponsiblePartyId());
164:
165:                /* null out partyType and set networkId result should be the same */
166:                this .reviewer.setPartyType(null);
167:                this .reviewer.setNetworkId("rkirkend");
168:                assertNull(
169:                        "ResponsibilityId is being set when only networkId is set",
170:                        this .reviewer.getResponsiblePartyId());
171:
172:                /* give two legal's and the set should be there */
173:                this .reviewer.setPartyType("U");
174:                assertNotNull(
175:                        "ResponsibilityId is not being set with a legal partyType "
176:                                + "and legal networkId", this .reviewer
177:                                .getResponsiblePartyId());
178:
179:                /* give an illegal combo and null should come back again */
180:                this .reviewer.setPartyType("W");
181:                assertNull("ResponsibilityId is being set with a bad partyType"
182:                        + "/networkId combo", this .reviewer
183:                        .getResponsiblePartyId());
184:
185:                /* give the other illegal combo and again null should be the case */
186:                this .reviewer.setPartyType("U");
187:                this .reviewer.setNetworkId("I'm evil Ash");
188:                assertNull("ResponsibilityId is being set with a bad partyType"
189:                        + "/networkId combo", this .reviewer
190:                        .getResponsiblePartyId());
191:            }
192:
193:            /**
194:             * can this guy populate himself w/ xml he made.
195:             */
196:            public void testCanFeedOnOwnXML() {
197:                reviewer.setNetworkId(networkId);
198:                reviewer.setPartyType(partyType);
199:
200:                Element reviewerEl = reviewer.getXMLContent();
201:
202:                ReviewerElement aReviewer = new ReviewerElement();
203:
204:                try {
205:                    aReviewer.loadFromXMLContent(reviewerEl, false);
206:                    assertEquals(
207:                            "Didn't properly load props from self generated "
208:                                    + "element", networkId, aReviewer
209:                                    .getNetworkId());
210:                    assertEquals(
211:                            "Didn't properly load props from self generated "
212:                                    + "element", partyType, aReviewer
213:                                    .getPartyType());
214:                } catch (Exception ex) {
215:                    fail("threw exception loading from self made element");
216:                }
217:            }
218:
219:            /**
220:             * this test is in response to a bug.  The responsiblePartyId wasn't being set
221:             * when reviewer was loaded from xmlContent.
222:             */
223:            public void testresponsiblePartyIdBeingSetFromXMLContent() {
224:                this .reviewer.setNetworkId(this .networkId);
225:                this .reviewer.setPartyType(this .partyType);
226:
227:                /* verify that indeed that is a valid set of values before proceeding,
228:                   well at least that it's not null... */
229:                assertNotNull(
230:                        "valid reviewer user and party type returned null "
231:                                + "responsiblePartyId", this .reviewer
232:                                .getResponsiblePartyId());
233:
234:                /* get the xmlContent and make a new reviewer from it */
235:                Element el = this .reviewer.getXMLContent();
236:                ReviewerElement aReviewer = new ReviewerElement();
237:
238:                try {
239:                    aReviewer.loadFromXMLContent(el, false);
240:                } catch (Exception ex) {
241:                    ex.printStackTrace();
242:                    fail("threw exception loading from valid xml");
243:                }
244:
245:                assertNotNull(
246:                        "valid reviewer user and party type returned null "
247:                                + "responsiblePartyId after being loaded from xml.  "
248:                                + "The responsiblePartyId is not being set in the loading "
249:                                + "of the xml", aReviewer
250:                                .getResponsiblePartyId());
251:            }
252:        }
253:
254:        /*
255:         * Copyright 2003 The Trustees of Indiana University.  All rights reserved.
256:         *
257:         * This file is part of the EDEN software package.
258:         * For license information, see the LICENSE file in the top level directory
259:         * of the EDEN source distribution.
260:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.