diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/interceptors/input/src/main/app/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/interceptors/input/src/main/app/mule-config.xml new file mode 100644 index 000000000..89926b134 --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/interceptors/input/src/main/app/mule-config.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/interceptors/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/interceptors/output/report/report.json new file mode 100644 index 000000000..81b5dd159 --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/interceptors/output/report/report.json @@ -0,0 +1,159 @@ +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [], + "numberOfMuleComponents": 21, + "numberOfMuleComponentsMigrated": 11, + "componentDetails": { + "mule": { + "success": 1, + "failure": 0 + }, + "flow": { + "success": 3, + "failure": 0 + }, + "interceptor-stack": { + "success": 0, + "failure": 3 + }, + "custom-interceptor": { + "success": 0, + "failure": 5 + }, + "logging-interceptor": { + "success": 0, + "failure": 1 + }, + "timer-interceptor": { + "success": 0, + "failure": 1 + }, + "echo-component": { + "success": 1, + "failure": 0 + }, + "set-payload": { + "success": 1, + "failure": 0 + }, + "logger": { + "success": 3, + "failure": 0 + }, + "raise-error": { + "success": 2, + "failure": 0 + } + }, + "numberOfMELExpressions": 0, + "numberOfMELExpressionsMigrated": 0, + "numberOfMELExpressionLines": 0, + "numberOfMELExpressionLinesMigrated": 0, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [ + { + "level": "ERROR", + "key": "components.interceptors", + "component": "interceptor-stack", + "lineNumber": 4, + "columnNumber": 37, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.interceptors", + "component": "custom-interceptor", + "lineNumber": 8, + "columnNumber": 124, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.interceptors", + "component": "custom-interceptor", + "lineNumber": 16, + "columnNumber": 62, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.interceptors", + "component": "logging-interceptor", + "lineNumber": 22, + "columnNumber": 30, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.interceptors", + "component": "interceptor-stack", + "lineNumber": 28, + "columnNumber": 40, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.interceptors", + "component": "timer-interceptor", + "lineNumber": 34, + "columnNumber": 28, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.interceptors", + "component": "interceptor-stack", + "lineNumber": 44, + "columnNumber": 44, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.interceptors", + "component": "custom-interceptor", + "lineNumber": 55, + "columnNumber": 128, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.interceptors", + "component": "custom-interceptor", + "lineNumber": 65, + "columnNumber": 128, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.interceptors", + "component": "custom-interceptor", + "lineNumber": 75, + "columnNumber": 128, + "message": "Interceptors have been replaced by custom policies in Mule 4.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + } + ] +} \ No newline at end of file diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/interceptors/output/src/main/mule/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/interceptors/output/src/main/mule/mule-config.xml new file mode 100644 index 000000000..fed00b03f --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/interceptors/output/src/main/mule/mule-config.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/InterceptorElements.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/InterceptorElements.java new file mode 100644 index 000000000..a0646e6f9 --- /dev/null +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/InterceptorElements.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020, Mulesoft, LLC. All rights reserved. + * Use of this source code is governed by a BSD 3-Clause License + * license that can be found in the LICENSE.txt file. + */ +package com.mulesoft.tools.migration.library.mule.steps.core; + +import com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep; +import com.mulesoft.tools.migration.step.category.MigrationReport; + +import org.jdom2.Element; + +/** + * Unsupported interceptor elements. + * + * @author Mulesoft Inc. + * @since 1.0.0 + */ +public class InterceptorElements extends AbstractApplicationModelMigrationStep { + + public static final String XPATH_SELECTOR = "" + + "//*[" + + "local-name()='interceptor-stack' or " + + "local-name()='custom-interceptor' or " + + "local-name()='logging-interceptor' or " + + "local-name()='timer-interceptor'" + + "]"; + + @Override + public String getDescription() { + return "Interceptor elements are no longer supported"; + } + + public InterceptorElements() { + this.setAppliedTo(XPATH_SELECTOR); + } + + @Override + public void execute(Element object, MigrationReport report) throws RuntimeException { + report.report("components.interceptors", object, object, object.getName()); + } + +} diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/JavaReferenceElements.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/JavaReferenceElements.java index 26161eb97..0f9221ed5 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/JavaReferenceElements.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/JavaReferenceElements.java @@ -36,7 +36,6 @@ public class JavaReferenceElements extends AbstractApplicationModelMigrationStep + "local-name()='custom-processing-strategy' or " + "local-name()='custom-transaction-manager' or " + "local-name()='custom-security-filter' or " - + "local-name()='custom-interceptor' or " + "local-name()='custom-transformer' or " // actually deprecated + "local-name()='custom-exception-strategy' or " + "local-name()='custom-connector' or " diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemovedElements.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemovedElements.java index b11082528..17e9b5000 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemovedElements.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemovedElements.java @@ -21,8 +21,7 @@ public class RemovedElements extends AbstractApplicationModelMigrationStep { public static final String XPATH_SELECTOR = "" + "//*[" + "local-name()='static-component' or " - + "local-name()='dynamic-all' or " - + "local-name()='interceptor-stack'" + + "local-name()='dynamic-all'" + "]"; @Override diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/EchoComponent.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/EchoComponent.java index ebad69387..c6f88cf55 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/EchoComponent.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/EchoComponent.java @@ -35,10 +35,8 @@ public EchoComponent() { @Override public void execute(Element object, MigrationReport report) throws RuntimeException { if (!object.getChildren().isEmpty()) { - report.report("components.interceptors", object, object); object.setName("set-payload"); object.setAttribute("value", "#[payload]"); - object.removeContent(); } else { object.detach(); } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/LogComponent.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/LogComponent.java index a5c980601..a47d8c9d4 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/LogComponent.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/LogComponent.java @@ -35,10 +35,6 @@ public LogComponent() { @Override public void execute(Element object, MigrationReport report) throws RuntimeException { object.setName("logger"); - if (!object.getChildren().isEmpty()) { - report.report("components.interceptors", object, object); - object.removeContent(); - } object.setAttribute("message", "#[payload]"); } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/NullComponent.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/NullComponent.java index 74eb68e04..0b58be145 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/NullComponent.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/component/NullComponent.java @@ -35,10 +35,6 @@ public NullComponent() { @Override public void execute(Element object, MigrationReport report) throws RuntimeException { object.setName("raise-error"); - if (!object.getChildren().isEmpty()) { - report.report("components.interceptors", object, object); - object.removeContent(); - } object.setAttribute("type", "COMPATIBILITY:UNSUPPORTED"); object.setAttribute("description", "This service cannot receive messages"); } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/tasks/MuleDeprecatedCoreComponentsMigrationTask.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/tasks/MuleDeprecatedCoreComponentsMigrationTask.java index b320f8a59..2f15aa461 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/tasks/MuleDeprecatedCoreComponentsMigrationTask.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/tasks/MuleDeprecatedCoreComponentsMigrationTask.java @@ -15,6 +15,7 @@ import com.mulesoft.tools.migration.library.mule.steps.core.CopyProperties; import com.mulesoft.tools.migration.library.mule.steps.core.DataMapper; import com.mulesoft.tools.migration.library.mule.steps.core.ExpressionComponent; +import com.mulesoft.tools.migration.library.mule.steps.core.InterceptorElements; import com.mulesoft.tools.migration.library.mule.steps.core.JavaReferenceElements; import com.mulesoft.tools.migration.library.mule.steps.core.MessageAttachmentsListExpressionEvaluator; import com.mulesoft.tools.migration.library.mule.steps.core.MessagePropertiesTransformer; @@ -63,6 +64,7 @@ public String getFrom() { @Override public List getSteps() { return newArrayList(new CompatibilityPomContribution(), + new InterceptorElements(), new EchoComponent(), new LogComponent(), new NullComponent(), diff --git a/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/mule/steps/core/ComponentTest.java b/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/mule/steps/core/ComponentTest.java index dda3b42b0..1cd84c0f4 100644 --- a/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/mule/steps/core/ComponentTest.java +++ b/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/mule/steps/core/ComponentTest.java @@ -66,6 +66,7 @@ public ComponentTest(String filePrefix) { private NullComponent nullComp; private RemovedElements removed; private JavaReferenceElements javaRef; + private InterceptorElements interceptors; @Before public void setUp() throws Exception { @@ -74,6 +75,7 @@ public void setUp() throws Exception { nullComp = new NullComponent(); removed = new RemovedElements(); javaRef = new JavaReferenceElements(); + interceptors = new InterceptorElements(); } @@ -91,6 +93,8 @@ public void execute() throws Exception { .forEach(node -> removed.execute(node, report.getReport())); getElementsFromDocument(doc, javaRef.getAppliedTo().getExpression()) .forEach(node -> javaRef.execute(node, report.getReport())); + getElementsFromDocument(doc, interceptors.getAppliedTo().getExpression()) + .forEach(node -> interceptors.execute(node, report.getReport())); XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); String xmlString = outputter.outputString(doc); diff --git a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-01i.xml b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-01i.xml index 2d8ef44ca..a3eb72e23 100644 --- a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-01i.xml +++ b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-01i.xml @@ -5,7 +5,9 @@ http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"> - + + + diff --git a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-01ig.xml b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-01ig.xml index c5255607c..ac471f94e 100644 --- a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-01ig.xml +++ b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-01ig.xml @@ -10,7 +10,9 @@ - + + + diff --git a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-02i.xml b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-02i.xml index d588eefd1..a00560cd5 100644 --- a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-02i.xml +++ b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-02i.xml @@ -5,7 +5,9 @@ http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"> - + + + diff --git a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-02ig.xml b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-02ig.xml index bbb1b6e4e..7761ef577 100644 --- a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-02ig.xml +++ b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-02ig.xml @@ -10,7 +10,9 @@ - + + + diff --git a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-03i.xml b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-03i.xml index 14939c5e3..5d10be200 100644 --- a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-03i.xml +++ b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-03i.xml @@ -5,7 +5,9 @@ http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"> - + + + diff --git a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-03ig.xml b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-03ig.xml index 40f04b51e..ef87a7c30 100644 --- a/mule-migration-tool-library/src/test/resources/mule/apps/core/component-03ig.xml +++ b/mule-migration-tool-library/src/test/resources/mule/apps/core/component-03ig.xml @@ -10,7 +10,9 @@ - + + +