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


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * 
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         * 
009:         * http://www.opensource.org/licenses/ecl1.php
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.xml.export;
018:
019:        import java.io.BufferedInputStream;
020:        import java.io.ByteArrayInputStream;
021:        import java.util.HashSet;
022:        import java.util.Iterator;
023:        import java.util.List;
024:        import java.util.Set;
025:
026:        import org.junit.Test;
027:
028:        import edu.iu.uis.eden.KEWServiceLocator;
029:        import edu.iu.uis.eden.doctype.DocumentType;
030:        import edu.iu.uis.eden.doctype.DocumentTypePolicy;
031:        import edu.iu.uis.eden.engine.node.BranchPrototype;
032:        import edu.iu.uis.eden.engine.node.Process;
033:        import edu.iu.uis.eden.engine.node.RouteNode;
034:        import edu.iu.uis.eden.export.ExportDataSet;
035:        import edu.iu.uis.eden.export.ExportFormat;
036:
037:        public class DocumentTypeXmlExporterTest extends XmlExporterTestCase {
038:
039:            @Test
040:            public void testExportDynamicProcessConfig() throws Exception {
041:                loadXmlFile("DocTypeExportRuleTemplateConfig.xml");
042:                loadXmlFile("DocTypeExportConfig.xml");
043:                assertExport();
044:            }
045:
046:            protected void assertExport() throws Exception {
047:                List documentTypes = KEWServiceLocator.getDocumentTypeService()
048:                        .findAllCurrent();
049:                for (Iterator iterator = documentTypes.iterator(); iterator
050:                        .hasNext();) {
051:                    DocumentType existingDocType = (DocumentType) iterator
052:                            .next();
053:                    ExportDataSet dataSet = new ExportDataSet(ExportFormat.XML);
054:                    dataSet.getDocumentTypes().add(existingDocType);
055:                    byte[] xmlBytes = KEWServiceLocator.getXmlExporterService()
056:                            .export(ExportFormat.XML, dataSet);
057:                    assertTrue("XML should be non empty.", xmlBytes != null
058:                            && xmlBytes.length > 0);
059:                    loadXmlStream(new BufferedInputStream(
060:                            new ByteArrayInputStream(xmlBytes)));
061:                    DocumentType newDocType = KEWServiceLocator
062:                            .getDocumentTypeService().findByName(
063:                                    existingDocType.getName());
064:                    assertDocTypeExport(existingDocType, newDocType);
065:                }
066:            }
067:
068:            // TODO delyea - check this
069:            private void assertDocTypeExport(DocumentType oldDocType,
070:                    DocumentType newDocType) {
071:                // assert fields which should be different
072:                assertFalse("Document type ids should be different.",
073:                        oldDocType.getDocumentTypeId().equals(
074:                                newDocType.getDocumentTypeId()));
075:                assertTrue("Version should be one greater.", newDocType
076:                        .getVersion().intValue() == oldDocType.getVersion()
077:                        .intValue() + 1);
078:                assertEquals("Previous version should be old doc type.",
079:                        oldDocType.getDocumentTypeId(), newDocType
080:                                .getPreviousVersionId());
081:
082:                // assert fields which should be the same
083:                assertEquals("Should have same name", oldDocType.getName(),
084:                        newDocType.getName());
085:                if (oldDocType.getParentDocType() == null) {
086:                    assertNull("Should have same parent.", newDocType
087:                            .getParentDocType());
088:                } else {
089:                    assertEquals("Should have same parent.", oldDocType
090:                            .getParentDocType().getName(), newDocType
091:                            .getParentDocType().getName());
092:                }
093:                assertEquals(oldDocType.getActiveInd(), newDocType
094:                        .getActiveInd());
095:                assertEquals(oldDocType.getDescription(), newDocType
096:                        .getDescription());
097:                assertEquals(oldDocType.getDocHandlerUrl(), newDocType
098:                        .getDocHandlerUrl());
099:                assertEquals(oldDocType.getLabel(), newDocType.getLabel());
100:                assertEquals(oldDocType.getPostProcessorName(), newDocType
101:                        .getPostProcessorName());
102:                assertEquals(oldDocType.getRoutingVersion(), newDocType
103:                        .getRoutingVersion());
104:                assertEquals(oldDocType.getBlanketApproveWorkgroup()
105:                        .getWorkflowGroupId(), newDocType
106:                        .getBlanketApproveWorkgroup().getWorkflowGroupId());
107:                assertEquals(oldDocType.getBlanketApprovePolicy(), newDocType
108:                        .getBlanketApprovePolicy());
109:                assertEquals(oldDocType.getCurrentInd(), newDocType
110:                        .getCurrentInd());
111:                assertEquals(oldDocType.getSuperUserWorkgroup()
112:                        .getWorkflowGroupId(), newDocType
113:                        .getSuperUserWorkgroup().getWorkflowGroupId());
114:                assertEquals(oldDocType.getNotificationFromAddress(),
115:                        newDocType.getNotificationFromAddress());
116:                assertRoutePath(oldDocType, newDocType);
117:                assertPolicies(oldDocType, newDocType);
118:            }
119:
120:            private void assertRoutePath(DocumentType oldDocType,
121:                    DocumentType newDocType) {
122:                for (Iterator iterator = oldDocType.getProcesses().iterator(); iterator
123:                        .hasNext();) {
124:                    Process oldProcess = (Process) iterator.next();
125:                    Process newProcess = newDocType.getNamedProcess(oldProcess
126:                            .getName());
127:                    assertRouteNodes(oldProcess.getInitialRouteNode(),
128:                            newProcess.getInitialRouteNode(), new HashSet());
129:                }
130:            }
131:
132:            private void assertRouteNodes(RouteNode oldNode, RouteNode newNode,
133:                    Set processedNodeIds) {
134:                if (processedNodeIds.contains(oldNode.getRouteNodeId())) {
135:                    if (!processedNodeIds.contains(newNode.getRouteNodeId())) {
136:                        fail("If old node is processed, new node should also be processed.");
137:                    }
138:                    return;
139:                }
140:                assertEquals(oldNode.getRouteNodeName(), newNode
141:                        .getRouteNodeName());
142:                assertEquals(oldNode.getActivationType(), newNode
143:                        .getActivationType());
144:                assertEquals(oldNode.getExceptionWorkgroupId(), newNode
145:                        .getExceptionWorkgroupId());
146:                assertEquals(oldNode.getNodeType(), newNode.getNodeType());
147:                assertEquals(oldNode.getRouteMethodCode(), newNode
148:                        .getRouteMethodCode());
149:                assertEquals(oldNode.getRouteMethodName(), newNode
150:                        .getRouteMethodName());
151:                assertEquals(oldNode.getDocumentType().getName(), newNode
152:                        .getDocumentType().getName());
153:                assertEquals(oldNode.getFinalApprovalInd(), newNode
154:                        .getFinalApprovalInd());
155:                assertEquals(oldNode.getMandatoryRouteInd(), newNode
156:                        .getMandatoryRouteInd());
157:                assertBranches(oldNode.getBranch(), newNode.getBranch());
158:                assertEquals(oldNode.getNextNodes().size(), newNode
159:                        .getNextNodes().size());
160:                processedNodeIds.add(oldNode.getRouteNodeId());
161:                processedNodeIds.add(newNode.getRouteNodeId());
162:                for (Iterator iterator = oldNode.getNextNodes().iterator(); iterator
163:                        .hasNext();) {
164:                    RouteNode nextOldNode = (RouteNode) iterator.next();
165:                    boolean foundNode = false;
166:                    for (Iterator iterator2 = newNode.getNextNodes().iterator(); iterator2
167:                            .hasNext();) {
168:                        RouteNode nextNewNode = (RouteNode) iterator2.next();
169:                        if (nextNewNode.getRouteNodeName().equals(
170:                                nextOldNode.getRouteNodeName())) {
171:                            foundNode = true;
172:                            assertRouteNodes(nextOldNode, nextNewNode,
173:                                    processedNodeIds);
174:                            break;
175:                        }
176:                    }
177:                    assertTrue("Could not locate new node by name: "
178:                            + nextOldNode.getRouteNodeName(), foundNode);
179:                }
180:            }
181:
182:            private void assertBranches(BranchPrototype oldBranch,
183:                    BranchPrototype newBranch) {
184:                if (oldBranch == null) {
185:                    assertNull("New Branch should also be null.", newBranch);
186:                } else {
187:                    assertEquals(oldBranch.getName(), newBranch.getName());
188:                }
189:            }
190:
191:            private void assertPolicies(DocumentType oldDocType,
192:                    DocumentType newDocType) {
193:                assertEquals(oldDocType.getPolicies().size(), newDocType
194:                        .getPolicies().size());
195:                for (Iterator iterator = oldDocType.getPolicies().iterator(); iterator
196:                        .hasNext();) {
197:                    DocumentTypePolicy oldPolicy = (DocumentTypePolicy) iterator
198:                            .next();
199:                    boolean foundPolicy = false;
200:                    for (Iterator iterator2 = newDocType.getPolicies()
201:                            .iterator(); iterator2.hasNext();) {
202:                        DocumentTypePolicy newPolicy = (DocumentTypePolicy) iterator2
203:                                .next();
204:                        if (oldPolicy.getPolicyName().equals(
205:                                newPolicy.getPolicyName())) {
206:                            foundPolicy = true;
207:                            assertEquals(oldPolicy.getInheritedFlag(),
208:                                    newPolicy.getInheritedFlag());
209:                            assertEquals(oldPolicy.getPolicyValue(), newPolicy
210:                                    .getPolicyValue());
211:                            break;
212:                        }
213:                    }
214:                    assertTrue("Could not locate policy by name "
215:                            + oldPolicy.getPolicyName(), foundPolicy);
216:                }
217:            }
218:
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.