|
21 | 21 |
|
22 | 22 | public class MuleToJavaDSLDwlTransformTest extends JavaDSLActionBaseTest { |
23 | 23 |
|
24 | | - private static final String muleXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
| 24 | + private static final String muleXmlSetPayload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
25 | 25 | "\n" + |
26 | 26 | "<mule xmlns:dw=\"http://www.mulesoft.org/schema/mule/ee/dw\" xmlns:http=\"http://www.mulesoft.org/schema/mule/http\" xmlns=\"http://www.mulesoft.org/schema/mule/core\" xmlns:doc=\"http://www.mulesoft.org/schema/mule/documentation\"\n" + |
27 | 27 | " xmlns:spring=\"http://www.springframework.org/schema/beans\" \n" + |
@@ -78,8 +78,8 @@ public class MuleToJavaDSLDwlTransformTest extends JavaDSLActionBaseTest { |
78 | 78 | "</mule>"; |
79 | 79 |
|
80 | 80 | @Test |
81 | | - public void shouldTranslateDwlTransformation() { |
82 | | - addXMLFileToResource(muleXml); |
| 81 | + public void shouldTranslateDwlTransformationWithSetPayload() { |
| 82 | + addXMLFileToResource(muleXmlSetPayload); |
83 | 83 | runAction(); |
84 | 84 | assertThat(projectContext.getProjectJavaSources().list()).hasSize(2); |
85 | 85 | assertThat(projectContext.getProjectJavaSources().list().get(0).print()) |
@@ -127,7 +127,7 @@ public void shouldTranslateDwlTransformation() { |
127 | 127 | } |
128 | 128 |
|
129 | 129 | @Test |
130 | | - public void shouldTransformDWLWithFile() { |
| 130 | + public void shouldTransformDWLWithFileWithSetPayload() { |
131 | 131 | addXMLFileToResource(dwlXMLWithExternalFile); |
132 | 132 | runAction(); |
133 | 133 | assertThat(projectContext.getProjectJavaSources().list()).hasSize(2); |
@@ -168,4 +168,57 @@ public void shouldTransformDWLWithFile() { |
168 | 168 | " }\n" + |
169 | 169 | "}"); |
170 | 170 | } |
| 171 | + |
| 172 | + @Test |
| 173 | + public void shouldTranslateDWLTransformationWithOnlyOneSetVariable() { |
| 174 | + String muleXMLSetVariable = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
| 175 | + "\n" + |
| 176 | + "<mule xmlns:dw=\"http://www.mulesoft.org/schema/mule/ee/dw\" xmlns:http=\"http://www.mulesoft.org/schema/mule/http\" xmlns=\"http://www.mulesoft.org/schema/mule/core\" xmlns:doc=\"http://www.mulesoft.org/schema/mule/documentation\"\n" + |
| 177 | + " xmlns:spring=\"http://www.springframework.org/schema/beans\" \n" + |
| 178 | + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + |
| 179 | + " xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd\n" + |
| 180 | + "http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd\n" + |
| 181 | + "http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd\n" + |
| 182 | + "http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd\">\n" + |
| 183 | + " <flow name=\"dwlFlow\">\n" + |
| 184 | + " <http:listener config-ref=\"HTTP_Listener_Configuration\" path=\"/dwl\" doc:name=\"HTTP\"/>\n" + |
| 185 | + " \n" + |
| 186 | + " <dw:transform-message doc:name=\"action transform\">\n" + |
| 187 | + " <dw:set-variable variableName=\"temp\"><![CDATA[%dw 1.0\n" + |
| 188 | + "%output application/json\n" + |
| 189 | + "---\n" + |
| 190 | + "{\n" + |
| 191 | + " action_Code: 10,\n" + |
| 192 | + " returnCode: 20\n" + |
| 193 | + "}]]>\n" + |
| 194 | + " \n" + |
| 195 | + " </dw:set-variable>\n" + |
| 196 | + " </dw:transform-message>\n" + |
| 197 | + " \n" + |
| 198 | + " <logger message=\"Hello World: #[flowVars.temp]\" level=\"INFO\" doc:name=\"Log the message content to be sent\"/>\n" + |
| 199 | + " </flow>\n" + |
| 200 | + "</mule>"; |
| 201 | + addXMLFileToResource(muleXMLSetVariable); |
| 202 | + runAction(); |
| 203 | + assertThat(projectContext.getProjectJavaSources().list()).hasSize(1); |
| 204 | + assertThat(projectContext.getProjectJavaSources().list().get(0).print()) |
| 205 | + .isEqualTo( |
| 206 | + "package com.example.javadsl;\n" + |
| 207 | + "import org.springframework.context.annotation.Bean;\n" + |
| 208 | + "import org.springframework.context.annotation.Configuration;\n" + |
| 209 | + "import org.springframework.integration.dsl.IntegrationFlow;\n" + |
| 210 | + "import org.springframework.integration.dsl.IntegrationFlows;\n" + |
| 211 | + "import org.springframework.integration.handler.LoggingHandler;\n" + |
| 212 | + "import org.springframework.integration.http.dsl.Http;\n" + |
| 213 | + "\n" + |
| 214 | + "@Configuration\n" + |
| 215 | + "public class FlowConfigurations {\n" + |
| 216 | + " @Bean\n" + |
| 217 | + " IntegrationFlow dwlFlow() {\n" + |
| 218 | + " return IntegrationFlows.from(Http.inboundChannelAdapter(\"/dwl\")).handle((p, h) -> p)\n" + |
| 219 | + " // FIXME: No support for following DW transformation: <dw:set-property/> <dw:set-session-variable /> <dw:set-variable />\n" + |
| 220 | + " .log(LoggingHandler.Level.INFO, \"Hello World: ${flowVars.temp}\")\n" + |
| 221 | + " .get();\n" + |
| 222 | + " }}"); |
| 223 | + } |
171 | 224 | } |
0 commit comments