1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.edl.impl;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertNotNull;
21 import static org.junit.Assert.assertTrue;
22
23 import java.util.Map;
24
25 import org.junit.Test;
26 import org.kuali.rice.core.api.config.property.Config;
27 import org.kuali.rice.core.api.config.property.ConfigContext;
28 import org.kuali.rice.edl.impl.service.EDocLiteService;
29 import org.kuali.rice.edl.impl.service.EdlServiceLocator;
30 import org.kuali.rice.kew.test.KEWTestCase;
31 import org.springframework.mock.web.MockHttpServletRequest;
32 import org.w3c.dom.Element;
33
34
35 public class EDLControllerTest extends KEWTestCase {
36
37 protected void loadTestData() throws Exception {
38 super.loadXmlFile("widgets.xml");
39 super.loadXmlFile("edlstyle.xml");
40 super.loadXmlFile("FakeyEDL.xml");
41 }
42
43 @Test public void testEDLControllerCreation() throws Exception {
44 ConfigContext.getCurrentContextConfig().putProperty(Config.EDL_CONFIG_LOCATION, "classpath:org/kuali/rice/kew/edl/TestEDLConfig.xml");
45
46
47 EDLController edlController = getEDLService().getEDLControllerUsingEdlName("FakeyEDL");
48 edlController.setEdlContext(getEDLcontext());
49 assertNotNull("There should be a default dom in the edlcontoller", edlController.getDefaultDOM());
50 edlController.notifyComponents();
51
52 assertTrue("PreProcess component should have been notified", TestPreProcessor.isContacted());
53 assertTrue("PostProcessor component should have been notified", TestPostProcessor.isContacted());
54 assertTrue("State component should have been notified", TestStateComponent.isContacted());
55 assertTrue("ConfigProcess component should have been notified", TestConfigProcessor.isContacted());
56
57
58 Element preProcessorConfigElement = (Element) ((Map.Entry)edlController.getEdlGlobalConfig().getPreProcessors().entrySet().iterator().next()).getKey();
59 assertEquals("PreProcessor config element is of the wrong class", "org.kuali.rice.edl.impl.TestPreProcessor", preProcessorConfigElement.getFirstChild().getNodeValue());
60
61 Element postProcessorConfigElement = (Element) ((Map.Entry)edlController.getEdlGlobalConfig().getPostProcessors().entrySet().iterator().next()).getKey();
62 assertEquals("PostProcessor config element is of the wrong class", "org.kuali.rice.edl.impl.TestPostProcessor", postProcessorConfigElement.getFirstChild().getNodeValue());
63
64 Element stateConfigElement = (Element) ((Map.Entry)edlController.getEdlGlobalConfig().getStateComponents().entrySet().iterator().next()).getKey();
65 assertEquals("State config element is of the wrong class", "org.kuali.rice.edl.impl.TestStateComponent", stateConfigElement.getFirstChild().getNodeValue());
66
67 Element configProcessorConfigElement = (Element) ((Map.Entry)edlController.getConfigProcessors().entrySet().iterator().next()).getKey();
68 assertEquals("Config processor element should be fielDef", "fieldDef", configProcessorConfigElement.getNodeName());
69
70 }
71
72 private EDLContext getEDLcontext() {
73 EDLContext edlContext = new EDLContext();
74 edlContext.setRequestParser(new RequestParser(new MockHttpServletRequest()));
75 return edlContext;
76 }
77
78 private EDocLiteService getEDLService() {
79 return EdlServiceLocator.getEDocLiteService();
80 }
81
82 }