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