From 5718d342145c6c38204f99825cbd8cbbac42f963 Mon Sep 17 00:00:00 2001 From: svacas Date: Tue, 15 Feb 2022 12:30:38 -0300 Subject: [PATCH] Migration Cost JSON report (#601) + support jdk 13+ + build with LTS jdks 8, 11 and 17 --- .github/workflows/maven.yml | 48 +--- README.md | 5 +- mule-migration-tool-api/pom.xml | 23 ++ ...AbstractApplicationModelMigrationStep.java | 16 +- .../tools/migration/step/ReportingStep.java | 128 +++++++++ .../ApplicationModelContribution.java | 5 + .../category/ComponentMigrationStatus.java | 33 +++ .../step/category/MigrationReport.java | 129 +++++++++ .../migration/task/AbstractMigrationTask.java | 16 +- mule-migration-tool-e2e-tests/pom.xml | 4 - .../e2e/AbstractEndToEndTestCase.java | 9 +- .../e2e/IntegrationAppsTestCase.java | 34 +++ .../migration/e2e/MigrationGapsTestCase.java | 35 +++ .../e2e/UntilSuccessfulMigrationTestCase.java | 4 +- .../resources/e2e/amqp1Mvn/output/pom.xml | 132 ++++----- .../output/src/main/mule/mule-config.xml | 80 +++--- .../e2e/domain1/output/report/report.json | 49 +++- .../src/main/mule/mule-domain-config.xml | 22 +- .../e2e/domain1app1/output/report/report.json | 135 ++++++--- .../output/src/main/mule/domain1app1.xml | 74 ++--- .../input/src/main/app/mule-config.xml | 15 + .../unknown_element/output/report/report.json | 30 ++ .../output/src/main/mule/mule-config.xml | 16 ++ .../input/src/main/app/mule-config.xml | 18 ++ .../output/report/report.json | 59 ++++ .../output/src/main/mule/mule-config.xml | 25 ++ .../output/report/report.json | 145 ++++++---- .../input/src/main/app/mule-config.xml | 58 ++++ .../integration/demo_connect/output/pom.xml | 63 +++++ .../demo_connect/output/report/report.json | 262 ++++++++++++++++++ .../output/src/main/mule/mule-config.xml | 170 ++++++++++++ .../output/report/report.json | 117 +++++--- .../secure-property/output/report/report.json | 135 ++++++--- .../test/resources/e2e/soapkit/output/pom.xml | 2 +- .../e2e/soapkit/output/report/report.json | 165 +++++++---- .../output/src/main/mule/mule-config.xml | 228 +++++++-------- .../input/src/main/app/mule-config.xml | 0 .../until_successful_01}/output/pom.xml | 2 +- .../output/src/main/mule/mule-config.xml | 1 - .../input/src/main/app/mule-config.xml | 0 .../until_successful_02}/output/pom.xml | 2 +- .../output/src/main/mule/mule-config.xml | 0 .../output/report/report.json | 135 ++++++--- .../src/test/resources/log4j2-test.xml | 4 +- .../tools/migration/engine/MigrationJob.java | 7 +- .../report/DefaultMigrationReport.java | 200 +++++++++++-- .../report/html/model/ReportEntryModel.java | 21 +- .../migration/report/json/JSONReport.java | 152 ++++++++-- .../ErrorResponseBuilderMigrationStep.java | 5 - .../http/ResponseBuilderMigrationStep.java | 5 - .../mule/steps/core/ExpressionComponent.java | 1 + .../core/KeepElementsAtBottomOfFlow.java | 5 + .../mule/steps/core/PreprocessNamespaces.java | 1 + .../steps/core/RemoveMetadataAttributes.java | 5 + .../RemoveSyntheticMigrationAttributes.java | 6 + .../library/mule/steps/ee/EETransform.java | 9 +- .../mule/steps/ee/MigrateDWScriptFiles.java | 9 +- .../tools/MelToDwExpressionMigrator.java | 7 + .../mel/DefaultMelCompatibilityResolver.java | 2 +- .../library/tools/mel/Encode64Resolver.java | 2 + .../FunctionExpressionEvaluatorResolver.java | 1 + ...boundAttachmentsCompatibilityResolver.java | 2 +- ...nboundPropertiesCompatibilityResolver.java | 1 + ...cationPropertiesCompatibilityResolver.java | 1 + ...tboundPropertiesCompatibilityResolver.java | 7 +- ...SessionVariablesCompatibilityResolver.java | 1 + .../mel/VariablesCompatibilityResolver.java | 1 + ...xedTimeAlgorithmMigrationStepTestCase.java | 4 - ...laBasedAlgorithmMigrationStepTestCase.java | 4 - pom.xml | 61 ++-- .../tools/migration/MigrationRunner.java | 10 +- scripts/update-e2e-tests-output.groovy | 39 +++ 72 files changed, 2509 insertions(+), 693 deletions(-) create mode 100644 mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/ReportingStep.java create mode 100644 mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/ComponentMigrationStatus.java create mode 100644 mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/IntegrationAppsTestCase.java create mode 100644 mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/MigrationGapsTestCase.java create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/input/src/main/app/mule-config.xml create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/output/report/report.json create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/output/src/main/mule/mule-config.xml create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/input/src/main/app/mule-config.xml create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/output/report/report.json create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/output/src/main/mule/mule-config.xml create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/input/src/main/app/mule-config.xml create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/pom.xml create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/report/report.json create mode 100644 mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/src/main/mule/mule-config.xml rename mule-migration-tool-e2e-tests/src/test/resources/e2e/{until-successful-01 => until_successful/until_successful_01}/input/src/main/app/mule-config.xml (100%) rename mule-migration-tool-e2e-tests/src/test/resources/e2e/{until-successful-01 => until_successful/until_successful_01}/output/pom.xml (97%) rename mule-migration-tool-e2e-tests/src/test/resources/e2e/{until-successful-01 => until_successful/until_successful_01}/output/src/main/mule/mule-config.xml (98%) rename mule-migration-tool-e2e-tests/src/test/resources/e2e/{until-successful-02 => until_successful/until_successful_02}/input/src/main/app/mule-config.xml (100%) rename mule-migration-tool-e2e-tests/src/test/resources/e2e/{until-successful-02 => until_successful/until_successful_02}/output/pom.xml (97%) rename mule-migration-tool-e2e-tests/src/test/resources/e2e/{until-successful-02 => until_successful/until_successful_02}/output/src/main/mule/mule-config.xml (100%) create mode 100644 scripts/update-e2e-tests-output.groovy diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 1b2437bda..bc3c3430e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -10,37 +10,19 @@ on: branches: [ master ] jobs: - build-linux: + build: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + jdk: [1.8, 1.11, 1.17] # LTS versions + include: + - os: ubuntu-latest + mvn-settings: '/home/runner/.m2/settings.xml' + - os: windows-latest + mvn-settings: 'C:\Users\runneradmin\.m2\settings.xml' - steps: - - name: checkout - uses: actions/checkout@v2 - - - name: maven-settings-xml-action - uses: whelk-io/maven-settings-xml-action@v10 - with: - repositories: '[{ "id": "mulesoft-public", "url": "https://repository.mulesoft.org/nexus/content/repositories/public" }, - { "id": "mule-releases", "url": "https://repository.mulesoft.org/releases" }]' - - - name: log-settings - run: cat \/home\/runner\/.m2\/settings.xml - - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - - name: mvn-version - run: mvn --version - - - name: Build with Maven - run: mvn --settings /home/runner/.m2/settings.xml clean install --file pom.xml - - build-windows: - - runs-on: windows-latest + runs-on: ${{ matrix.os }} steps: - name: checkout @@ -53,15 +35,15 @@ jobs: { "id": "mule-releases", "url": "https://repository.mulesoft.org/releases" }]' - name: log-settings - run: cat C:\Users\runneradmin\.m2\settings.xml + run: cat ${{ matrix.mvn-settings }} - - name: Set up JDK 1.8 + - name: Set up JDK ${{ matrix.jdk }} uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: ${{ matrix.jdk }} - name: mvn-version run: mvn --version - name: Build with Maven - run: mvn --settings C:\Users\runneradmin\.m2\settings.xml clean install --file pom.xml + run: mvn --settings ${{ matrix.mvn-settings }} clean install --file pom.xml diff --git a/README.md b/README.md index 934ce4b94..b30f2d479 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ If you would just like to download/access the MMA tool (compiled version), you c See the following commands in order to clone, build and run this project ``` -$ git clone --recursive git@github.com:mulesoft/mule-migration-tool.git -$ cd mule-migration-tool/ +$ git clone --recursive git@github.com:mulesoft/mule-migration-assistant.git +$ cd mule-migration-assistant/ $ mvn clean package $ cd runner/target $ java -jar mule-migration-assistant-runner-*CURRENT VERSION*.jar [parameters] @@ -72,6 +72,7 @@ $ java -jar mule-migration-assistant-runner-*CURRENT VERSION*.jar [parameters] | help | Show all the parameters to define on MMA | No | | cancelOnError | Use cancelOnError = true the MMA stop migration if a exception occurs (default false) | No | | projectParentGAV | Use projectParentGAV 'groupId:artifactId:version' to migrate your parent inside the pom.xml | No | +| jsonReport | Generate migration report in JSON format | No | ### User Documentation diff --git a/mule-migration-tool-api/pom.xml b/mule-migration-tool-api/pom.xml index 8282b282a..5fd10680b 100644 --- a/mule-migration-tool-api/pom.xml +++ b/mule-migration-tool-api/pom.xml @@ -60,6 +60,29 @@ + + + surefire-java15plus + + [1.15,) + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens java.base/java.io=ALL-UNNAMED + --add-opens java.base/java.lang=ALL-UNNAMED + + + + + + + + org.jdom diff --git a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/AbstractApplicationModelMigrationStep.java b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/AbstractApplicationModelMigrationStep.java index b603459e1..ceab562ac 100644 --- a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/AbstractApplicationModelMigrationStep.java +++ b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/AbstractApplicationModelMigrationStep.java @@ -6,17 +6,22 @@ package com.mulesoft.tools.migration.step; import static com.google.common.base.Preconditions.checkArgument; +import static com.mulesoft.tools.migration.step.category.MigrationReport.Level.ERROR; import com.mulesoft.tools.migration.exception.MigrationStepException; import com.mulesoft.tools.migration.project.model.ApplicationModel; import com.mulesoft.tools.migration.step.category.ApplicationModelContribution; +import com.mulesoft.tools.migration.step.category.MigrationReport; +import java.util.ArrayList; +import java.util.List; + +import org.jdom2.Element; import org.jdom2.Namespace; import org.jdom2.xpath.XPathExpression; import org.jdom2.xpath.XPathFactory; - -import java.util.ArrayList; -import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Basic unit of execution. @@ -69,4 +74,9 @@ public List getNamespacesContributions() { public void setNamespacesContributions(List namespaces) { this.namespacesContribution = namespaces; } + + @Override + public boolean shouldReportMetrics() { + return true; + } } diff --git a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/ReportingStep.java b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/ReportingStep.java new file mode 100644 index 000000000..195906ee3 --- /dev/null +++ b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/ReportingStep.java @@ -0,0 +1,128 @@ +/* + * 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.step; + +import static com.mulesoft.tools.migration.step.category.MigrationReport.Level.ERROR; + +import com.mulesoft.tools.migration.project.model.ApplicationModel; +import com.mulesoft.tools.migration.step.category.ApplicationModelContribution; +import com.mulesoft.tools.migration.step.category.MigrationReport; +import com.mulesoft.tools.migration.util.ExpressionMigrator; + +import java.util.List; + +import org.jdom2.Element; +import org.jdom2.Namespace; +import org.jdom2.xpath.XPathExpression; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Wrapper of ApplicationModelContribution steps that enables detailed reporting + * of the element migration result. + * + * @author Mulesoft Inc. + */ +public class ReportingStep implements ApplicationModelContribution, ExpressionMigratorAware { + + private static final Logger logger = LoggerFactory.getLogger(ReportingStep.class); + + private final ApplicationModelContribution targetStep; + + public ReportingStep(ApplicationModelContribution step) { + targetStep = step; + } + + /** + * Wraps the step execution in order to report the element migration result + * + * success: + * - report error count not increased OR + * - report error count increased same amount as mel/dw errors + * failure: + * - report error count > mel/dw errors OR + * - exception thrown + */ + @Override + public void execute(Element element, MigrationReport report) { + int entriesBefore = report.getReportEntries(ERROR).size(); + int melFailuresBefore = report.getMelExpressionsFailureCount(); + int dwFailuresBefore = report.getDwTransformsFailureCount(); + try { + targetStep.execute(element, report); + if (targetStep.shouldReportMetrics()) { + if (report.getReportEntries(ERROR).size() <= entriesBefore + (report.getMelExpressionsFailureCount() - melFailuresBefore) + + (report.getDwTransformsFailureCount() - dwFailuresBefore)) { + report.addComponentSuccess(element); + } else { + report.addComponentFailure(element); + } + } + } catch (Exception e) { + logger.warn("Exception {} -- migrating {}:{}", e, element != null ? element.getNamespacePrefix() : "null", + element != null ? element.getName() : "null"); + if (targetStep.shouldReportMetrics()) { + report.addComponentFailure(element); + } + throw e; + } + } + + @Override + public String getDescription() { + return targetStep.getDescription(); + } + + @Override + public XPathExpression getAppliedTo() { + return targetStep.getAppliedTo(); + } + + @Override + public void setAppliedTo(String xpathExpression) { + targetStep.setAppliedTo(xpathExpression); + } + + @Override + public ApplicationModel getApplicationModel() { + return targetStep.getApplicationModel(); + } + + @Override + public void setApplicationModel(ApplicationModel appModel) { + targetStep.setApplicationModel(appModel); + } + + @Override + public List getNamespacesContributions() { + return targetStep.getNamespacesContributions(); + } + + @Override + public void setNamespacesContributions(List namespaces) { + targetStep.setNamespacesContributions(namespaces); + } + + @Override + public boolean shouldReportMetrics() { + return targetStep.shouldReportMetrics(); + } + + @Override + public void setExpressionMigrator(ExpressionMigrator expressionMigrator) { + if (targetStep instanceof ExpressionMigratorAware) { + ((ExpressionMigratorAware) targetStep).setExpressionMigrator(expressionMigrator); + } + } + + @Override + public ExpressionMigrator getExpressionMigrator() { + if (targetStep instanceof ExpressionMigratorAware) { + return ((ExpressionMigratorAware) targetStep).getExpressionMigrator(); + } + return null; + } +} diff --git a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/ApplicationModelContribution.java b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/ApplicationModelContribution.java index ad6add3e0..1d1d6364d 100644 --- a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/ApplicationModelContribution.java +++ b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/ApplicationModelContribution.java @@ -63,4 +63,9 @@ public interface ApplicationModelContribution extends MigrationStep { * @return a {@link ApplicationModel} */ void setNamespacesContributions(List namespaces); + + /** + * Whether this step should report migration result metrics or not. + */ + boolean shouldReportMetrics(); } diff --git a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/ComponentMigrationStatus.java b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/ComponentMigrationStatus.java new file mode 100644 index 000000000..8ed8b65b8 --- /dev/null +++ b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/ComponentMigrationStatus.java @@ -0,0 +1,33 @@ +/* + * 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.step.category; + +/** + * Indicates the migration result, either success or failure for all the instances of a given component. + * + * @author Mulesoft Inc. + */ +public class ComponentMigrationStatus { + + private int success; + private int failure; + + public int getSuccess() { + return success; + } + + public int getFailure() { + return failure; + } + + public void success() { + success++; + } + + public void failure() { + failure++; + } +} diff --git a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/MigrationReport.java b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/MigrationReport.java index 733d3dba7..8df566561 100644 --- a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/MigrationReport.java +++ b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/step/category/MigrationReport.java @@ -6,11 +6,13 @@ package com.mulesoft.tools.migration.step.category; import com.mulesoft.tools.migration.project.ProjectType; +import com.mulesoft.tools.migration.project.model.pom.PomModel; import org.jdom2.Element; import java.nio.file.Path; import java.util.List; +import java.util.Map; /** * An interface to feed the migration report. @@ -89,6 +91,125 @@ public enum Level { */ void addProcessedElements(int processedElements); + /** + * Returns the type of the migrated project. + */ + String getProjectType(); + + /** + * Returns the name of the migrated project. + */ + String getProjectName(); + + /** + * Returns a list of connectors migrated. + */ + List getConnectorNames(); + + /** + * Retrieves the migrated connectors from the POM. + * + * @param pomModel POM from where the migrated connectors are retrieved. + */ + void addConnectors(PomModel pomModel); + + /** + * Number of components successfully migrated. + */ + Integer getComponentSuccessCount(); + + /** + * Number of components that where not migrated successfully. + */ + Integer getComponentFailureCount(); + + /** + * Migration status summary by component. + */ + Map getComponents(); + + /** + * Increments the component success migration count. + * + * @param element component migrated with no errors. + */ + void addComponentSuccess(Element element); + + /** + * Increments the component failure migration count. + * + * @param element component migrated with errors. + */ + void addComponentFailure(Element element); + + /** + * Number of DataWeave scripts migrated successfully. + */ + Integer getDwTransformsSuccessCount(); + + /** + * Number of DataWeave scripts migrated unsuccessfully. + */ + Integer getDwTransformsFailureCount(); + + /** + * Number of DataWeave script lines migrated successfully. + */ + Integer getDwTransformsSuccessLineCount(); + + /** + * Number of DataWeave script lines migrated unsuccessfully. + */ + Integer getDwTransformsFailureLineCount(); + + /** + * Reports a successful DataWeave script migration. + * + * @param script DataWeave script migrated. + */ + void dwTransformsSuccess(String script); + + /** + * Reports an unsuccessful DataWeave script migration. + * + * @param script DataWeave script unsuccessfully migrated. + */ + void dwTransformsFailure(String script); + + /** + * Number of MEL expressions migrated successfully. + */ + Integer getMelExpressionsSuccessCount(); + + /** + * Number of MEL expressions migrated unsuccessfully. + */ + Integer getMelExpressionsFailureCount(); + + /** + * Number of MEL expression lines migrated successfully. + */ + Integer getMelExpressionsSuccessLineCount(); + + /** + * Number of MEL expression lines migrated unsuccessfully. + */ + Integer getMelExpressionsFailureLineCount(); + + /** + * Reports a successful MEL expression migration. + * + * @param melExpression MEL expression migrated. + */ + void melExpressionSuccess(String melExpression); + + /** + * Reports an unsuccessful MEL expression migration. + * + * @param melExpression MEL expression unsuccessfully migrated. + */ + void melExpressionFailure(String melExpression); + /** * Update file reference on report * @@ -101,4 +222,12 @@ public enum Level { * Returns the report entries. */ List getReportEntries(); + + /** + * Returns the report entries for the given levels. + * + * @param levels to filter report entries returned. + */ + List getReportEntries(Level... levels); + } diff --git a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/task/AbstractMigrationTask.java b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/task/AbstractMigrationTask.java index 902080acb..a95ec0894 100644 --- a/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/task/AbstractMigrationTask.java +++ b/mule-migration-tool-api/src/main/java/com/mulesoft/tools/migration/task/AbstractMigrationTask.java @@ -16,6 +16,7 @@ import com.mulesoft.tools.migration.project.model.pom.PomModel; import com.mulesoft.tools.migration.step.ExpressionMigratorAware; import com.mulesoft.tools.migration.step.MigrationStep; +import com.mulesoft.tools.migration.step.ReportingStep; import com.mulesoft.tools.migration.step.category.ApplicationModelContribution; import com.mulesoft.tools.migration.step.category.MigrationReport; import com.mulesoft.tools.migration.util.ExpressionMigrator; @@ -26,6 +27,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; /** * A task is composed by one or more steps @@ -55,7 +57,7 @@ public void setApplicationModel(ApplicationModel applicationModel) { public void execute(MigrationReport report) throws Exception { // TODO depending on the project type this may not be true checkState(applicationModel != null, "An application model must be provided."); - List steps = getSteps(); + List steps = enableReporting(getSteps()); try { if (steps != null) { @@ -95,6 +97,18 @@ public void execute(MigrationReport report) throws Exception { } } + private List enableReporting(List steps) { + if (steps != null) { + return steps.stream().map(step -> { + if (step instanceof ApplicationModelContribution) { + return new ReportingStep((ApplicationModelContribution) step); + } + return step; + }).collect(Collectors.toList()); + } + return null; + } + private void fetchAndProcessNodes(MigrationReport report, ApplicationModelContribution s, List alreadyProcessed) { AtomicInteger processedElements = new AtomicInteger(0); diff --git a/mule-migration-tool-e2e-tests/pom.xml b/mule-migration-tool-e2e-tests/pom.xml index 9389c3ed3..fe4ced2fa 100644 --- a/mule-migration-tool-e2e-tests/pom.xml +++ b/mule-migration-tool-e2e-tests/pom.xml @@ -45,10 +45,6 @@ org.jacoco jacoco-maven-plugin - - org.apache.maven.plugins - maven-dependency-plugin - org.apache.maven.plugins maven-surefire-plugin diff --git a/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/AbstractEndToEndTestCase.java b/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/AbstractEndToEndTestCase.java index f2a1fe1f8..dce95e963 100644 --- a/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/AbstractEndToEndTestCase.java +++ b/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/AbstractEndToEndTestCase.java @@ -84,7 +84,6 @@ protected String migrate(String projectName, String... additionalParams) throws final String projectBasePath = new File(getResourceUri("e2e/" + projectName + "/input")).getAbsolutePath(); final String outPutPath = migrationResult.getRoot().toPath().resolve(projectName).toAbsolutePath().toString(); - System.setProperty(MigrationRunner.JSON_REPORT_PROP_NAME, "true"); // Run migration tool final List command = buildMigratorArgs(projectBasePath, outPutPath, projectName); @@ -107,7 +106,8 @@ private List buildMigratorArgs(String projectBasePath, String outPutPath command.add("-muleVersion"); command.add(RUNTIME_VERSION); command.add("-projectGAV"); - command.add(":" + projectName + ":"); + command.add(":" + projectName.replaceAll(".*/", "") + ":"); + command.add("-jsonReport"); return command; } @@ -168,8 +168,9 @@ private void compareJson(Path expected, Path migratedPath) { } private void normalizeFilePath(JsonElement report) { - if (report.isJsonArray()) { - report.getAsJsonArray().forEach(e -> { + String messagesKey = "detailedMessages"; + if (report.isJsonObject() && report.getAsJsonObject().has(messagesKey)) { + report.getAsJsonObject().get(messagesKey).getAsJsonArray().forEach(e -> { String filePathKey = "filePath"; if (e.isJsonObject() && e.getAsJsonObject().has(filePathKey)) { String filePath = e.getAsJsonObject().get(filePathKey).getAsString(); diff --git a/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/IntegrationAppsTestCase.java b/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/IntegrationAppsTestCase.java new file mode 100644 index 000000000..5c3f88a9d --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/IntegrationAppsTestCase.java @@ -0,0 +1,34 @@ +/* + * 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.e2e; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + + +@RunWith(Parameterized.class) +public class IntegrationAppsTestCase extends AbstractEndToEndTestCase { + + @Parameters(name = "{0}") + public static Object[] params() { + return new Object[] { + "integration/demo_connect" + }; + } + + private final String appToMigrate; + + public IntegrationAppsTestCase(String appToMigrate) { + this.appToMigrate = appToMigrate; + } + + @Test + public void test() throws Exception { + simpleCase(appToMigrate); + } +} diff --git a/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/MigrationGapsTestCase.java b/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/MigrationGapsTestCase.java new file mode 100644 index 000000000..87064b1bf --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/MigrationGapsTestCase.java @@ -0,0 +1,35 @@ +/* + * 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.e2e; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + + +@RunWith(Parameterized.class) +public class MigrationGapsTestCase extends AbstractEndToEndTestCase { + + @Parameters(name = "{0}") + public static Object[] params() { + return new Object[] { + "gaps/unknown_element", + "gaps/unknown_namespace" + }; + } + + private final String appToMigrate; + + public MigrationGapsTestCase(String appToMigrate) { + this.appToMigrate = appToMigrate; + } + + @Test + public void test() throws Exception { + simpleCase(appToMigrate); + } +} diff --git a/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/UntilSuccessfulMigrationTestCase.java b/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/UntilSuccessfulMigrationTestCase.java index e541f6695..36bb97c4c 100644 --- a/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/UntilSuccessfulMigrationTestCase.java +++ b/mule-migration-tool-e2e-tests/src/test/java/com/mulesoft/tools/migration/e2e/UntilSuccessfulMigrationTestCase.java @@ -17,8 +17,8 @@ public class UntilSuccessfulMigrationTestCase extends AbstractEndToEndTestCase { @Parameters(name = "{0}") public static Object[] params() { return new Object[] { - "until-successful-01", - "until-successful-02" + "until_successful/until_successful_01", + "until_successful/until_successful_02" }; } diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/amqp1Mvn/output/pom.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/amqp1Mvn/output/pom.xml index 61aca33ea..8f355e1a5 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/amqp1Mvn/output/pom.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/amqp1Mvn/output/pom.xml @@ -1,69 +1,69 @@ - 4.0.0 - org.mule.corp - amqpOneMaven - 1.0.0-M4-SNAPSHOT - mule-application - amqp1Mvn - Application migrated with MMA - - UTF-8 - UTF-8 - 3.8.4 - 1.7 - - - - com.mulesoft.mule.modules - mule-compatibility-module - 1.4.0 - mule-plugin - - - com.mulesoft.connectors - mule-amqp-connector - 1.7.2 - mule-plugin - - - - - Central - Central - http://repo1.maven.org/maven2/ - - - mulesoft-releases - MuleSoft Releases Repository - https://repository.mulesoft.org/releases/ - - - anypoint-exchange - Anypoint Exchange - https://maven.anypoint.mulesoft.com/api/v1/maven - - - - - - false - - mulesoft-release - mulesoft release repository - https://repository.mulesoft.org/releases/ - - - - - - org.mule.tools.maven - mule-maven-plugin - 3.2.1 - true - - - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + 4.0.0 + org.mule.corp + amqpOneMaven + 1.0.0-M4-SNAPSHOT + mule-application + amqp1Mvn + Application migrated with MMA + + 1.7 + UTF-8 + 3.8.4 + UTF-8 + + + + com.mulesoft.mule.modules + mule-compatibility-module + 1.4.0 + mule-plugin + + + com.mulesoft.connectors + mule-amqp-connector + 1.7.2 + mule-plugin + + + + + Central + Central + http://repo1.maven.org/maven2/ + + + mulesoft-releases + MuleSoft Releases Repository + https://repository.mulesoft.org/releases/ + + + anypoint-exchange + Anypoint Exchange + https://maven.anypoint.mulesoft.com/api/v1/maven + + + + + + false + + mulesoft-release + mulesoft release repository + https://repository.mulesoft.org/releases/ + + + + + + org.mule.tools.maven + mule-maven-plugin + 3.2.1 + true + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/amqp1Mvn/output/src/main/mule/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/amqp1Mvn/output/src/main/mule/mule-config.xml index 9afd4d517..d55db9680 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/amqp1Mvn/output/src/main/mule/mule-config.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/amqp1Mvn/output/src/main/mule/mule-config.xml @@ -1,40 +1,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1/output/report/report.json index 467292c2d..8f76d3cba 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1/output/report/report.json +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1/output/report/report.json @@ -1,10 +1,39 @@ -[ - { - "level": "WARN", - "lineNumber": 5, - "columnNumber": 112, - "message": "Threading profiles do not exist in Mule 4. You can replace them with a \u0027maxConcurrency\u0027 value in the flow.", - "filePath": "src/main/mule/mule-domain-config.xml", - "documentationLinks": [] - } -] +{ + "projectType": "MULE_THREE_DOMAIN", + "projectName": "input", + "connectorsMigrated": [ + "org.mule.connectors:mule-http-connector:1.5.25" + ], + "numberOfMuleComponents": 2, + "numberOfMuleComponentsMigrated": 2, + "componentDetails": { + "domain:mule-domain": { + "success": 1, + "failure": 0 + }, + "http:listener-config": { + "success": 1, + "failure": 0 + } + }, + "numberOfMELExpressions": 0, + "numberOfMELExpressionsMigrated": 0, + "numberOfMELExpressionLines": 0, + "numberOfMELExpressionLinesMigrated": 0, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [ + { + "level": "WARN", + "key": "flow.threading", + "component": "http:listener-config", + "lineNumber": 5, + "columnNumber": 112, + "message": "Threading profiles do not exist in Mule 4. You can replace them with a \u0027maxConcurrency\u0027 value in the flow.", + "filePath": "src/main/mule/mule-domain-config.xml", + "documentationLinks": [] + } + ] +} \ No newline at end of file diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1/output/src/main/mule/mule-domain-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1/output/src/main/mule/mule-domain-config.xml index 7c46c04b4..bdc59c1f9 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1/output/src/main/mule/mule-domain-config.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1/output/src/main/mule/mule-domain-config.xml @@ -1,9 +1,13 @@ - - - - - - - - - + + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1app1/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1app1/output/report/report.json index c74ed82f0..becf22d58 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1app1/output/report/report.json +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1app1/output/report/report.json @@ -1,42 +1,95 @@ -[ - { - "level": "WARN", - "lineNumber": 6, - "columnNumber": 113, - "message": "Avoid using an outbound property to determine the status code.", - "filePath": "src\\main\\mule\\domain1app1.xml", - "documentationLinks": [] +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [ + "org.mule.connectors:mule-http-connector:1.5.25" + ], + "numberOfMuleComponents": 6, + "numberOfMuleComponentsMigrated": 6, + "componentDetails": { + "mule": { + "success": 1, + "failure": 0 + }, + "domain:mule-domain": { + "success": 1, + "failure": 0 + }, + "logger": { + "success": 1, + "failure": 0 + }, + "flow": { + "success": 1, + "failure": 0 + }, + "http:listener-config": { + "success": 1, + "failure": 0 + }, + "http:listener": { + "success": 1, + "failure": 0 + } }, - { - "level": "WARN", - "lineNumber": 12, - "columnNumber": 141, - "message": "Avoid using an outbound property to determine the status code.", - "filePath": "src\\main\\mule\\domain1app1.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 16, - "columnNumber": 146, - "message": "Threading profiles do not exist in Mule 4. You can replace them with a \u0027maxConcurrency\u0027 value in the flow.", - "filePath": "{parentDomainBasePath}:\\src\\main\\domain\\mule-domain-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 20, - "columnNumber": 57, - "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", - "filePath": "src\\main\\mule\\domain1app1.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 29, - "columnNumber": 51, - "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", - "filePath": "src\\main\\mule\\domain1app1.xml", - "documentationLinks": [] - } -] + "numberOfMELExpressions": 0, + "numberOfMELExpressionsMigrated": 0, + "numberOfMELExpressionLines": 0, + "numberOfMELExpressionLinesMigrated": 0, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [ + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:response", + "lineNumber": 6, + "columnNumber": 113, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src\\main\\mule\\domain1app1.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:error-response", + "lineNumber": 12, + "columnNumber": 141, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src/main/mule/domain1app1.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "flow.threading", + "component": "http:listener-config", + "lineNumber": 16, + "columnNumber": 146, + "message": "Threading profiles do not exist in Mule 4. You can replace them with a \u0027maxConcurrency\u0027 value in the flow.", + "filePath": "{parentDomainBasePath}:/src/main/domain/mule-domain-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 20, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/domain1app1.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 29, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/domain1app1.xml", + "documentationLinks": [] + } + ] +} \ No newline at end of file diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1app1/output/src/main/mule/domain1app1.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1app1/output/src/main/mule/domain1app1.xml index 2b17b9bac..e9b1709dd 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1app1/output/src/main/mule/domain1app1.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/domain1app1/output/src/main/mule/domain1app1.xml @@ -1,37 +1,37 @@ - - - - - - - - - - #[migration::HttpListener::httpListenerResponseHeaders(vars)] - - - - - - #[migration::HttpListener::httpListenerResponseHeaders(vars)] - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + #[migration::HttpListener::httpListenerResponseHeaders(vars)] + + + + + + #[migration::HttpListener::httpListenerResponseHeaders(vars)] + + + + + + + + + + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/input/src/main/app/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/input/src/main/app/mule-config.xml new file mode 100644 index 000000000..9b39e45da --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/input/src/main/app/mule-config.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/output/report/report.json new file mode 100644 index 000000000..c013b1642 --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/output/report/report.json @@ -0,0 +1,30 @@ +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [], + "numberOfMuleComponents": 4, + "numberOfMuleComponentsMigrated": 4, + "componentDetails": { + "mule": { + "success": 1, + "failure": 0 + }, + "logger": { + "success": 2, + "failure": 0 + }, + "flow": { + "success": 1, + "failure": 0 + } + }, + "numberOfMELExpressions": 0, + "numberOfMELExpressionsMigrated": 0, + "numberOfMELExpressionLines": 0, + "numberOfMELExpressionLinesMigrated": 0, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [] +} \ No newline at end of file diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/output/src/main/mule/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/output/src/main/mule/mule-config.xml new file mode 100644 index 000000000..f4af07dfe --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_element/output/src/main/mule/mule-config.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/input/src/main/app/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/input/src/main/app/mule-config.xml new file mode 100644 index 000000000..cfde8ff1b --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/input/src/main/app/mule-config.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/output/report/report.json new file mode 100644 index 000000000..f47ab78db --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/output/report/report.json @@ -0,0 +1,59 @@ +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [], + "numberOfMuleComponents": 6, + "numberOfMuleComponentsMigrated": 4, + "componentDetails": { + "unknown:source": { + "success": 0, + "failure": 1 + }, + "unknown:operation": { + "success": 0, + "failure": 1 + }, + "mule": { + "success": 1, + "failure": 0 + }, + "logger": { + "success": 2, + "failure": 0 + }, + "flow": { + "success": 1, + "failure": 0 + } + }, + "numberOfMELExpressions": 0, + "numberOfMELExpressionsMigrated": 0, + "numberOfMELExpressionLines": 0, + "numberOfMELExpressionLinesMigrated": 0, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [ + { + "level": "ERROR", + "key": "components.unsupported", + "component": "unknown:source", + "lineNumber": 5, + "columnNumber": 25, + "message": "The migration of \u0027unknown\u0027 is not supported.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "components.unsupported", + "component": "unknown:operation", + "lineNumber": 16, + "columnNumber": 28, + "message": "The migration of \u0027unknown\u0027 is not supported.", + "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/unknown_namespace/output/src/main/mule/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/output/src/main/mule/mule-config.xml new file mode 100644 index 000000000..b646a7b72 --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/gaps/unknown_namespace/output/src/main/mule/mule-config.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/http/address_prop_placeholder/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/http/address_prop_placeholder/output/report/report.json index 9ddd6a4f1..6cd7a6216 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/http/address_prop_placeholder/output/report/report.json +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/http/address_prop_placeholder/output/report/report.json @@ -1,50 +1,97 @@ -[ - { - "level": "ERROR", - "lineNumber": 9, - "columnNumber": 66, - "message": "Unable to parse endpoint address '${http.address}'.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [ + "org.mule.connectors:mule-http-connector:1.5.25" + ], + "numberOfMuleComponents": 4, + "numberOfMuleComponentsMigrated": 3, + "componentDetails": { + "mule": { + "success": 1, + "failure": 0 + }, + "logger": { + "success": 1, + "failure": 0 + }, + "flow": { + "success": 1, + "failure": 0 + }, + "http:listener": { + "success": 0, + "failure": 1 + } }, - { - "level": "WARN", - "lineNumber": 10, - "columnNumber": 113, - "message": "Avoid using an outbound property to determine the status code.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 19, - "columnNumber": 141, - "message": "Avoid using an outbound property to determine the status code.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 27, - "columnNumber": 17, - "message": "This replicates logic from the HTTP transport. Remove it if it is not needed.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 34, - "columnNumber": 57, - "message": "Expressions that query 'inboundProperties' from the message should instead query the message 'attributes'. Remove this component if there are no uses of 'inboundProperties' in expressions or components that rely on 'inboundProperties' (such as 'copy-properties').", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 43, - "columnNumber": 51, - "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as 'method') of the operation or listener that accepts the expression.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - } -] \ No newline at end of file + "numberOfMELExpressions": 0, + "numberOfMELExpressionsMigrated": 0, + "numberOfMELExpressionLines": 0, + "numberOfMELExpressionLinesMigrated": 0, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [ + { + "level": "ERROR", + "key": "transports.cantParseAddress", + "component": "http:listener", + "lineNumber": 9, + "columnNumber": 66, + "message": "Unable to parse endpoint address \u0027${http.address}\u0027.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:response", + "lineNumber": 10, + "columnNumber": 113, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:error-response", + "lineNumber": 19, + "columnNumber": 141, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "http.checkPayload", + "component": "choice", + "lineNumber": 27, + "columnNumber": 17, + "message": "This replicates logic from the HTTP transport. Remove it if it is not needed.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 34, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 43, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "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/integration/demo_connect/input/src/main/app/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/input/src/main/app/mule-config.xml new file mode 100644 index 000000000..2cea60237 --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/input/src/main/app/mule-config.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/pom.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/pom.xml new file mode 100644 index 000000000..e55b603df --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + org.mule.migrated + demo_connect + 1.0.0-M4-SNAPSHOT + mule-application + Application migrated with MMA + + + com.mulesoft.mule.modules + mule-compatibility-module + 1.4.0 + mule-plugin + + + org.mule.connectors + mule-http-connector + 1.5.25 + mule-plugin + + + org.mule.connectors + mule-file-connector + 1.3.4 + mule-plugin + + + + + mulesoft-releases + MuleSoft Releases Repository + https://repository.mulesoft.org/releases/ + + + anypoint-exchange + Anypoint Exchange + https://maven.anypoint.mulesoft.com/api/v1/maven + + + + + + true + + mulesoft-releases + MuleSoft Releases Repository + https://repository.mulesoft.org/releases/ + + + + + + org.mule.tools.maven + mule-maven-plugin + 3.2.1 + true + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/report/report.json new file mode 100644 index 000000000..dccd855c0 --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/report/report.json @@ -0,0 +1,262 @@ +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [ + "org.mule.connectors:mule-http-connector:1.5.25", + "org.mule.connectors:mule-file-connector:1.3.4" + ], + "numberOfMuleComponents": 22, + "numberOfMuleComponentsMigrated": 21, + "componentDetails": { + "mule": { + "success": 1, + "failure": 0 + }, + "logger": { + "success": 1, + "failure": 0 + }, + "flow": { + "success": 3, + "failure": 0 + }, + "scheduler": { + "success": 1, + "failure": 0 + }, + "set-payload": { + "success": 1, + "failure": 0 + }, + "set-variable": { + "success": 1, + "failure": 0 + }, + "http:listener-config": { + "success": 1, + "failure": 0 + }, + "http:request-config": { + "success": 2, + "failure": 0 + }, + "http:listener": { + "success": 1, + "failure": 0 + }, + "http:request": { + "success": 2, + "failure": 1 + }, + "file:config": { + "success": 1, + "failure": 0 + }, + "file:write": { + "success": 1, + "failure": 0 + }, + "compatibility:set-property": { + "success": 1, + "failure": 0 + }, + "compatibility:copy-properties": { + "success": 2, + "failure": 0 + }, + "compatibility:remove-property": { + "success": 2, + "failure": 0 + } + }, + "numberOfMELExpressions": 2, + "numberOfMELExpressionsMigrated": 2, + "numberOfMELExpressionLines": 2, + "numberOfMELExpressionLinesMigrated": 2, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [ + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:response", + "lineNumber": 24, + "columnNumber": 113, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:error-response", + "lineNumber": 30, + "columnNumber": 141, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 38, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.copyProperties", + "component": "compatibility:copy-properties", + "lineNumber": 45, + "columnNumber": 57, + "message": "Instead of copying inbound properties in the flow, use the \u0027attributes\u0027 of the message directly.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:remove-property", + "lineNumber": 51, + "columnNumber": 62, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:set-property", + "lineNumber": 57, + "columnNumber": 139, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 63, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 73, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.copyProperties", + "component": "compatibility:copy-properties", + "lineNumber": 80, + "columnNumber": 57, + "message": "Instead of copying inbound properties in the flow, use the \u0027attributes\u0027 of the message directly.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:remove-property", + "lineNumber": 86, + "columnNumber": 62, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 92, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 111, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 121, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 128, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 136, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 148, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "http.port", + "component": "http:request", + "lineNumber": 154, + "columnNumber": 72, + "message": "\u0027port\u0027 cannot be overridden by the HTTP Request operation. You can use an expression in the config to make it dynamic. Original value was port\u003d\"#[flowVars.dynPort]\".", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 161, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "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/integration/demo_connect/output/src/main/mule/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/src/main/mule/mule-config.xml new file mode 100644 index 000000000..8e39d9ac1 --- /dev/null +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/integration/demo_connect/output/src/main/mule/mule-config.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + #[migration::HttpListener::httpListenerResponseHeaders(vars)] + + + + + + #[migration::HttpListener::httpListenerResponseHeaders(vars)] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #[migration::HttpRequester::httpRequesterHeaders(vars)] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #[migration::HttpRequester::httpRequesterHeaders(vars)] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #[migration::HttpRequester::httpRequesterHeaders(vars)] + + + + + + + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/jms/connector_spring_config/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/jms/connector_spring_config/output/report/report.json index 9e5113d80..8e9a09be0 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/jms/connector_spring_config/output/report/report.json +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/jms/connector_spring_config/output/report/report.json @@ -1,34 +1,85 @@ -[ - { - "level": "ERROR", - "lineNumber": 14, - "columnNumber": 98, - "message": "Cannot automatically migrate a JMS connection-factory defined as a spring bean.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [ + "org.mule.connectors:mule-jms-connector:1.8.2" + ], + "numberOfMuleComponents": 6, + "numberOfMuleComponentsMigrated": 5, + "componentDetails": { + "mule": { + "success": 1, + "failure": 0 + }, + "logger": { + "success": 1, + "failure": 0 + }, + "flow": { + "success": 1, + "failure": 0 + }, + "jms:listener": { + "success": 0, + "failure": 1 + }, + "jms:activemq-connector": { + "success": 1, + "failure": 0 + }, + "spring:beans": { + "success": 1, + "failure": 0 + } }, - { - "level": "WARN", - "lineNumber": 17, - "columnNumber": 145, - "message": "Avoid using properties to set the JMS response properties and headers.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 28, - "columnNumber": 57, - "message": "Expressions that query 'inboundProperties' from the message should instead query the message 'attributes'. Remove this component if there are no uses of 'inboundProperties' in expressions or components that rely on 'inboundProperties' (such as 'copy-properties').", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 37, - "columnNumber": 51, - "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as 'method') of the operation or listener that accepts the expression.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - } -] \ No newline at end of file + "numberOfMELExpressions": 1, + "numberOfMELExpressionsMigrated": 1, + "numberOfMELExpressionLines": 1, + "numberOfMELExpressionLinesMigrated": 1, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [ + { + "level": "ERROR", + "key": "jms.beanConnectionFactory", + "component": "jms:config", + "lineNumber": 14, + "columnNumber": 98, + "message": "Cannot automatically migrate a JMS connection-factory defined as a spring bean.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "jms.propertiesListener", + "component": "jms:listener", + "lineNumber": 17, + "columnNumber": 145, + "message": "Avoid using properties to set the JMS response properties and headers.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 28, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 37, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "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/secure-property/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/secure-property/output/report/report.json index 524c9f3b2..61c867e9d 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/secure-property/output/report/report.json +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/secure-property/output/report/report.json @@ -1,42 +1,95 @@ -[ - { - "level": "WARN", - "lineNumber": 4, - "columnNumber": 111, - "message": "In Mule 4, property keys referencing secure properties must contain the 'secure::' prefix. For example, a secure property called 'db.password' must be referenced as ${secure::db.password}. Review the usage of the secure properties defined in the referenced file and add the 'secure::' prefix accordingly.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [ + "org.mule.connectors:mule-http-connector:1.5.25" + ], + "numberOfMuleComponents": 6, + "numberOfMuleComponentsMigrated": 6, + "componentDetails": { + "secure-property-placeholder:config": { + "success": 1, + "failure": 0 + }, + "mule": { + "success": 1, + "failure": 0 + }, + "logger": { + "success": 1, + "failure": 0 + }, + "flow": { + "success": 1, + "failure": 0 + }, + "http:listener-config": { + "success": 1, + "failure": 0 + }, + "http:listener": { + "success": 1, + "failure": 0 + } }, - { - "level": "WARN", - "lineNumber": 18, - "columnNumber": 113, - "message": "Avoid using an outbound property to determine the status code.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 24, - "columnNumber": 141, - "message": "Avoid using an outbound property to determine the status code.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 32, - "columnNumber": 57, - "message": "Expressions that query 'inboundProperties' from the message should instead query the message 'attributes'. Remove this component if there are no uses of 'inboundProperties' in expressions or components that rely on 'inboundProperties' (such as 'copy-properties').", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 41, - "columnNumber": 51, - "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as 'method') of the operation or listener that accepts the expression.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - } -] \ No newline at end of file + "numberOfMELExpressions": 0, + "numberOfMELExpressionsMigrated": 0, + "numberOfMELExpressionLines": 0, + "numberOfMELExpressionLinesMigrated": 0, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [ + { + "level": "WARN", + "key": "configProperties.securePrefix", + "component": "secure-properties:config", + "lineNumber": 4, + "columnNumber": 111, + "message": "In Mule 4, property keys referencing secure properties must contain the \u0027secure::\u0027 prefix. For example, a secure property called \u0027db.password\u0027 must be referenced as ${secure::db.password}. Review the usage of the secure properties defined in the referenced file and add the \u0027secure::\u0027 prefix accordingly.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:response", + "lineNumber": 18, + "columnNumber": 113, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:error-response", + "lineNumber": 24, + "columnNumber": 141, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 32, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 41, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "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/soapkit/output/pom.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/pom.xml index 20d0d6bda..063b136ef 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/pom.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/pom.xml @@ -1,6 +1,6 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 org.mule.migrated soapkit diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/report/report.json index ae2cfefbe..48262f9da 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/report/report.json +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/report/report.json @@ -1,50 +1,117 @@ -[ - { - "level": "WARN", - "lineNumber": 12, - "columnNumber": 113, - "message": "Avoid using an outbound property to determine the status code.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [ + "org.mule.connectors:mule-http-connector:1.5.25" + ], + "numberOfMuleComponents": 15, + "numberOfMuleComponentsMigrated": 14, + "componentDetails": { + "mule": { + "success": 1, + "failure": 0 + }, + "flow": { + "success": 4, + "failure": 0 + }, + "set-payload": { + "success": 3, + "failure": 0 + }, + "ee:transform": { + "success": 1, + "failure": 0 + }, + "http:listener-config": { + "success": 1, + "failure": 0 + }, + "http:listener": { + "success": 1, + "failure": 0 + }, + "set-variable": { + "success": 0, + "failure": 1 + }, + "apikit-soap:config": { + "success": 1, + "failure": 0 + }, + "apikit-soap:router": { + "success": 2, + "failure": 0 + } }, - { - "level": "WARN", - "lineNumber": 19, - "columnNumber": 141, - "message": "Avoid using an outbound property to determine the status code.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 28, - "columnNumber": 57, - "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 47, - "columnNumber": 51, - "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "ERROR", - "lineNumber": 56, - "columnNumber": 93, - "message": "Refer to the documentation for the specific connector or operation to learn how to send attachments.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 78, - "columnNumber": 92, - "message": "Instead of setting outbound properties in the flow, you must set Mule 4 variables.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - } -] \ No newline at end of file + "numberOfMELExpressions": 0, + "numberOfMELExpressionsMigrated": 0, + "numberOfMELExpressionLines": 0, + "numberOfMELExpressionLinesMigrated": 0, + "numberOfDWTransformations": 1, + "numberOfDWTransformationsMigrated": 1, + "numberOfDWTransformationLines": 9, + "numberOfDWTransformationLinesMigrated": 9, + "detailedMessages": [ + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:response", + "lineNumber": 12, + "columnNumber": 113, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "http.statusCode", + "component": "http:error-response", + "lineNumber": 19, + "columnNumber": 141, + "message": "Avoid using an outbound property to determine the status code.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 28, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 47, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "message.outboundAttachments", + "component": "set-variable", + "lineNumber": 56, + "columnNumber": 93, + "message": "Refer to the documentation for the specific connector or operation to learn how to send attachments.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "transform.outboundProperties", + "component": "compatibility:set-property", + "lineNumber": 78, + "columnNumber": 92, + "message": "Instead of setting outbound properties in the flow, you must set Mule 4 variables.", + "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/soapkit/output/src/main/mule/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/src/main/mule/mule-config.xml index 946d8cd03..78f11c840 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/src/main/mule/mule-config.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/soapkit/output/src/main/mule/mule-config.xml @@ -1,88 +1,88 @@ - - - - - - - - - - - - - #[payload] - - - - #[attributes.protocolHeaders default {}] - - - #[payload] - - - - #[attributes.protocolHeaders default {}] - - - - - - - - - - - - #[payload] - #[%dw 2.0 -output application/java ---- -{ - headers: attributes.headers, - method: attributes.method, - queryString: attributes.queryString -}] - - - - - - - - - - - - - - - - - - - - - - %dw 2.0 -output application/xml -ns ns0 http://mulesoft.org/tshirt-service ---- -{ - ns0#APIUsageInformation: { - apiCallsRemaining: 10 - } -} - - - - - - - - - - - + + + + + + + + + + + + + #[payload] + + + + #[attributes.protocolHeaders default {}] + + + #[payload] + + + + #[attributes.protocolHeaders default {}] + + + + + + + + + + + + #[payload] + #[%dw 2.0 +output application/java +--- +{ + headers: attributes.headers, + method: attributes.method, + queryString: attributes.queryString +}] + + + + + + + + + + + + + + + + + + + + + + %dw 2.0 +output application/xml +ns ns0 http://mulesoft.org/tshirt-service +--- +{ + ns0#APIUsageInformation: { + apiCallsRemaining: 10 + } +} + + + + + + + + + + + - - - - - - - - - - +}]]> + + + + + + + + + + - - - - - - - - - - +}]]> + + + + + + + + + + - - - - - - +}]]> + + + + + + diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-01/input/src/main/app/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_01/input/src/main/app/mule-config.xml similarity index 100% rename from mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-01/input/src/main/app/mule-config.xml rename to mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_01/input/src/main/app/mule-config.xml diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-01/output/pom.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_01/output/pom.xml similarity index 97% rename from mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-01/output/pom.xml rename to mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_01/output/pom.xml index d79f4c732..0d237563e 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-01/output/pom.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_01/output/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 org.mule.migrated - until-successful-01 + until_successful_01 1.0.0-M4-SNAPSHOT mule-application Application migrated with MMA diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-01/output/src/main/mule/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_01/output/src/main/mule/mule-config.xml similarity index 98% rename from mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-01/output/src/main/mule/mule-config.xml rename to mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_01/output/src/main/mule/mule-config.xml index 1e1faab1b..b1c4050af 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-01/output/src/main/mule/mule-config.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_01/output/src/main/mule/mule-config.xml @@ -11,7 +11,6 @@ - diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-02/input/src/main/app/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_02/input/src/main/app/mule-config.xml similarity index 100% rename from mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-02/input/src/main/app/mule-config.xml rename to mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_02/input/src/main/app/mule-config.xml diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-02/output/pom.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_02/output/pom.xml similarity index 97% rename from mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-02/output/pom.xml rename to mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_02/output/pom.xml index 679a4ff72..678e7c359 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-02/output/pom.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_02/output/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 org.mule.migrated - until-successful-02 + until_successful_02 1.0.0-M4-SNAPSHOT mule-application Application migrated with MMA diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-02/output/src/main/mule/mule-config.xml b/mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_02/output/src/main/mule/mule-config.xml similarity index 100% rename from mule-migration-tool-e2e-tests/src/test/resources/e2e/until-successful-02/output/src/main/mule/mule-config.xml rename to mule-migration-tool-e2e-tests/src/test/resources/e2e/until_successful/until_successful_02/output/src/main/mule/mule-config.xml diff --git a/mule-migration-tool-e2e-tests/src/test/resources/e2e/ws_consumer/serviceAddress_prop_placeholder/output/report/report.json b/mule-migration-tool-e2e-tests/src/test/resources/e2e/ws_consumer/serviceAddress_prop_placeholder/output/report/report.json index 5c6582e7d..70977ddeb 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/e2e/ws_consumer/serviceAddress_prop_placeholder/output/report/report.json +++ b/mule-migration-tool-e2e-tests/src/test/resources/e2e/ws_consumer/serviceAddress_prop_placeholder/output/report/report.json @@ -1,42 +1,95 @@ -[ - { - "level": "ERROR", - "lineNumber": 0, - "columnNumber": 0, - "message": "Unable to parse endpoint address '${TestService}'.", - "filePath": "", - "documentationLinks": [] +{ + "projectType": "MULE_THREE_APPLICATION", + "projectName": "input", + "connectorsMigrated": [ + "org.mule.connectors:mule-wsc-connector:1.6.4" + ], + "numberOfMuleComponents": 6, + "numberOfMuleComponentsMigrated": 5, + "componentDetails": { + "mule": { + "success": 1, + "failure": 0 + }, + "on-error-continue": { + "success": 1, + "failure": 0 + }, + "flow": { + "success": 1, + "failure": 0 + }, + "wsc:config": { + "success": 0, + "failure": 1 + }, + "wsc:consume": { + "success": 1, + "failure": 0 + }, + "compatibility:set-property": { + "success": 1, + "failure": 0 + } }, - { - "level": "ERROR", - "lineNumber": 4, - "columnNumber": 39, - "message": "Web Service Consumer only supports HTTP or JMS transports.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 14, - "columnNumber": 51, - "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as 'method') of the operation or listener that accepts the expression.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 22, - "columnNumber": 57, - "message": "Expressions that query 'inboundProperties' from the message should instead query the message 'attributes'. Remove this component if there are no uses of 'inboundProperties' in expressions or components that rely on 'inboundProperties' (such as 'copy-properties').", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - }, - { - "level": "WARN", - "lineNumber": 31, - "columnNumber": 100, - "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as 'method') of the operation or listener that accepts the expression.", - "filePath": "src/main/mule/mule-config.xml", - "documentationLinks": [] - } -] \ No newline at end of file + "numberOfMELExpressions": 1, + "numberOfMELExpressionsMigrated": 1, + "numberOfMELExpressionLines": 1, + "numberOfMELExpressionLinesMigrated": 1, + "numberOfDWTransformations": 0, + "numberOfDWTransformationsMigrated": 0, + "numberOfDWTransformationLines": 0, + "numberOfDWTransformationLinesMigrated": 0, + "detailedMessages": [ + { + "level": "ERROR", + "key": "transports.cantParseAddress", + "component": "wsc:connection", + "lineNumber": 0, + "columnNumber": 0, + "message": "Unable to parse endpoint address \u0027${TestService}\u0027.", + "filePath": "", + "documentationLinks": [] + }, + { + "level": "ERROR", + "key": "wsc.unsupportedProtocol", + "component": "wsc:config", + "lineNumber": 4, + "columnNumber": 39, + "message": "Web Service Consumer only supports HTTP or JMS transports.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:outbound-properties-to-var", + "lineNumber": 14, + "columnNumber": 51, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.attributesToInboundProperties", + "component": "compatibility:attributes-to-inbound-properties", + "lineNumber": 22, + "columnNumber": 57, + "message": "Expressions that query \u0027inboundProperties\u0027 from the message should instead query the message \u0027attributes\u0027. Remove this component if there are no uses of \u0027inboundProperties\u0027 in expressions or components that rely on \u0027inboundProperties\u0027 (such as \u0027copy-properties\u0027).", + "filePath": "src/main/mule/mule-config.xml", + "documentationLinks": [] + }, + { + "level": "WARN", + "key": "message.outboundProperties", + "component": "compatibility:set-property", + "lineNumber": 31, + "columnNumber": 100, + "message": "Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as \u0027method\u0027) of the operation or listener that accepts the expression.", + "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/log4j2-test.xml b/mule-migration-tool-e2e-tests/src/test/resources/log4j2-test.xml index 752e6a345..9217cc4f4 100644 --- a/mule-migration-tool-e2e-tests/src/test/resources/log4j2-test.xml +++ b/mule-migration-tool-e2e-tests/src/test/resources/log4j2-test.xml @@ -2,7 +2,7 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/engine/MigrationJob.java b/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/engine/MigrationJob.java index 8b9ea2f79..cc5be639d 100644 --- a/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/engine/MigrationJob.java +++ b/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/engine/MigrationJob.java @@ -117,7 +117,7 @@ public void execute(MigrationReport report) throws Exception { } } } finally { - generateReport(report); + generateReport(report, applicationModel); } } @@ -183,7 +183,7 @@ private ApplicationModel generateTargetApplicationModel(Path project, ProjectTyp } } - private void generateReport(MigrationReport report) throws Exception { + private void generateReport(MigrationReport report, ApplicationModel applicationModel) throws Exception { List reportEntries = report.getReportEntries(); for (ReportEntryModel entry : reportEntries) { try { @@ -195,7 +195,8 @@ private void generateReport(MigrationReport report) throws Exc HTMLReport htmlReport = new HTMLReport(report.getReportEntries(), reportPath.toFile(), this.getRunnerVersion()); htmlReport.printReport(); if (jsonReportEnabled) { - JSONReport jsonReport = new JSONReport(report.getReportEntries(), reportPath.toFile(), outputProject); + applicationModel.getPomModel().ifPresent(p -> report.addConnectors(p)); + JSONReport jsonReport = new JSONReport(report, reportPath.toFile(), outputProject); jsonReport.printReport(); } } diff --git a/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/DefaultMigrationReport.java b/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/DefaultMigrationReport.java index 6879b0b79..5eb87fa92 100644 --- a/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/DefaultMigrationReport.java +++ b/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/DefaultMigrationReport.java @@ -5,27 +5,40 @@ */ package com.mulesoft.tools.migration.report; +import static com.mulesoft.tools.migration.step.category.MigrationReport.Level.ERROR; +import static java.util.Collections.emptyList; +import static java.util.Collections.list; + import com.mulesoft.tools.migration.exception.MigrationAbortException; import com.mulesoft.tools.migration.project.ProjectType; +import com.mulesoft.tools.migration.project.model.pom.PomModel; import com.mulesoft.tools.migration.report.html.model.ReportEntryModel; +import com.mulesoft.tools.migration.step.category.ComponentMigrationStatus; import com.mulesoft.tools.migration.step.category.MigrationReport; import com.mulesoft.tools.migration.step.util.XmlDslUtils; -import org.jdom2.Comment; -import org.jdom2.Element; -import org.jdom2.output.XMLOutputter; -import org.yaml.snakeyaml.Yaml; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.nio.file.Path; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; -import static com.mulesoft.tools.migration.step.category.MigrationReport.Level.ERROR; -import static java.util.Collections.emptyList; -import static java.util.Collections.list; +import org.apache.commons.lang3.StringUtils; +import org.jdom2.Comment; +import org.jdom2.Element; +import org.jdom2.output.XMLOutputter; +import org.yaml.snakeyaml.Yaml; /** * Default implementation of a {@link MigrationReport}. @@ -48,6 +61,17 @@ public class DefaultMigrationReport implements MigrationReport private double errorMigrationRatio; private int processedElements; + private final Map components = new LinkedHashMap<>(); + private final Set connectors = new LinkedHashSet<>(); + private int dwTransformsSuccess; + private int dwTransformsFailure; + private int dwTransformLinesSuccess; + private int dwTransformLinesFailure; + private int melExpressionsSuccess; + private int melExpressionsFailure; + private int melLinesSuccess; + private int melLinesFailure; + public DefaultMigrationReport() { possibleEntries = new HashMap<>(); @@ -94,44 +118,51 @@ public void report(String entryKey, Element element, Element elementToComment, S result.append(message.substring(currentIndex)); final List docLinks = entryData.get("docLinks") != null ? (List) entryData.get("docLinks") : emptyList(); - report(level, element, elementToComment, result.toString(), docLinks.toArray(new String[docLinks.size()])); + report(entryKey, level, element, elementToComment, result.toString(), docLinks.toArray(new String[docLinks.size()])); } @Override public void report(Level level, Element element, Element elementToComment, String message, String... documentationLinks) { + report(null, level, element, elementToComment, message, documentationLinks); + } + + private void report(String entryKey, Level level, Element element, Element elementToComment, String message, + String... documentationLinks) { int i = 0; ReportEntryModel reportEntry; if (elementToComment != null) { if (elementToComment.getDocument() != null || element.getDocument() == null) { - reportEntry = new ReportEntryModel(level, elementToComment, message, documentationLinks); + reportEntry = new ReportEntryModel(entryKey, level, elementToComment, message, documentationLinks); } else { - reportEntry = new ReportEntryModel(level, elementToComment, message, element.getDocument(), documentationLinks); + reportEntry = new ReportEntryModel(entryKey, level, elementToComment, message, element.getDocument(), documentationLinks); } if (reportEntries.add(reportEntry)) { - if (elementToComment != null) { - elementToComment.addContent(i++, new Comment("Migration " + level.name() + ": " + message)); + elementToComment.addContent(i++, new Comment("Migration " + level.name() + ": " + sanitize(message))); - if (documentationLinks.length > 0) { - elementToComment.addContent(i++, new Comment(" For more information refer to:")); + if (documentationLinks.length > 0) { + elementToComment.addContent(i++, new Comment(" For more information refer to:")); - for (String link : documentationLinks) { - elementToComment.addContent(i++, new Comment(" * " + link)); - } + for (String link : documentationLinks) { + elementToComment.addContent(i++, new Comment(" * " + link)); } + } - if (element != elementToComment) { - XmlDslUtils.removeNestedComments(element); - elementToComment.addContent(i++, new Comment(outp.outputString(element))); - } + if (element != elementToComment) { + XmlDslUtils.removeNestedComments(element); + elementToComment.addContent(i, new Comment(outp.outputString(element))); } } } } + private String sanitize(String message) { + return message.replaceAll("--", " - - "); + } + @Override public void addProcessedElements(int processedElements) { this.processedElements += processedElements; @@ -162,6 +193,12 @@ public List getReportEntries() { return new ArrayList<>(this.reportEntries); } + @Override + public List getReportEntries(Level... levels) { + List levelList = Arrays.asList(levels); + return reportEntries.stream().filter(e -> levelList.contains(e.getLevel())).collect(Collectors.toList()); + } + public double getSuccessfulMigrationRatio() { return successfulMigrationRatio; } @@ -169,4 +206,123 @@ public double getSuccessfulMigrationRatio() { public double getErrorMigrationRatio() { return errorMigrationRatio; } + + @Override + public List getConnectorNames() { + return new ArrayList<>(connectors); + } + + @Override + public void addConnectors(PomModel pomModel) { + pomModel.getDependencies().stream() + .filter(d -> d.getGroupId().contains("connector") || d.getArtifactId().contains("connector")) + .forEach(d -> connectors.add(String.format("%s:%s:%s", d.getGroupId(), d.getArtifactId(), d.getVersion()))); + } + + @Override + public Integer getComponentSuccessCount() { + return components.values().stream().map(ComponentMigrationStatus::getSuccess).reduce(0, Integer::sum); + } + + @Override + public Integer getComponentFailureCount() { + return components.values().stream().map(ComponentMigrationStatus::getFailure).reduce(0, Integer::sum); + } + + @Override + public Map getComponents() { + return components; + } + + public static String getComponentKey(Element element) { + String prefix = StringUtils.isBlank(element.getNamespace().getPrefix()) ? "" : element.getNamespace().getPrefix() + ":"; + return prefix + element.getName(); + } + + @Override + public void addComponentSuccess(Element element) { + String name = getComponentKey(element); + components.putIfAbsent(name, new ComponentMigrationStatus()); + components.get(name).success(); + } + + @Override + public void addComponentFailure(Element element) { + String name = getComponentKey(element); + components.putIfAbsent(name, new ComponentMigrationStatus()); + components.get(name).failure(); + } + + @Override + public Integer getDwTransformsSuccessCount() { + return dwTransformsSuccess; + } + + @Override + public Integer getDwTransformsFailureCount() { + return dwTransformsFailure; + } + + @Override + public Integer getDwTransformsSuccessLineCount() { + return dwTransformLinesSuccess; + } + + @Override + public Integer getDwTransformsFailureLineCount() { + return dwTransformLinesFailure; + } + + @Override + public void dwTransformsSuccess(String script) { + this.dwTransformsSuccess++; + int lines = countLines(script); + this.dwTransformLinesSuccess += lines; + } + + @Override + public void dwTransformsFailure(String script) { + this.dwTransformsFailure++; + int lines = countLines(script); + this.dwTransformLinesFailure += lines; + } + + @Override + public Integer getMelExpressionsSuccessCount() { + return melExpressionsSuccess; + } + + @Override + public Integer getMelExpressionsFailureCount() { + return melExpressionsFailure; + } + + @Override + public Integer getMelExpressionsSuccessLineCount() { + return melLinesSuccess; + } + + @Override + public Integer getMelExpressionsFailureLineCount() { + return melLinesFailure; + } + + @Override + public void melExpressionSuccess(String melExpression) { + this.melExpressionsSuccess++; + int lines = countLines(melExpression); + this.melLinesSuccess += lines; + } + + @Override + public void melExpressionFailure(String melExpression) { + this.melExpressionsFailure++; + int lines = countLines(melExpression); + this.melLinesFailure += lines; + } + + private int countLines(String melExpression) { + return melExpression.split("\\r\\n|\\r|\\n").length; + } + } diff --git a/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/html/model/ReportEntryModel.java b/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/html/model/ReportEntryModel.java index c970a063f..376162106 100644 --- a/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/html/model/ReportEntryModel.java +++ b/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/html/model/ReportEntryModel.java @@ -45,6 +45,7 @@ public class ReportEntryModel { private final Level level; + private final String key; private final String elementContent; private transient Element element; private Integer lineNumber = 0; @@ -54,8 +55,9 @@ public class ReportEntryModel { private final List documentationLinks = new ArrayList<>(); - public ReportEntryModel(Level level, Element element, String message, String... documentationLinks) { + public ReportEntryModel(String key, Level level, Element element, String message, String... documentationLinks) { this.level = level; + this.key = key; this.elementContent = element != null ? escapeXml11(domElementToString(element)) : ""; this.element = element; this.message = message; @@ -69,8 +71,17 @@ public ReportEntryModel(Level level, Element element, String message, String... this.documentationLinks.addAll(asList(documentationLinks)); } - public ReportEntryModel(Level level, Element element, String message, Document document, String... documentationLinks) { - this(level, element, message, documentationLinks); + private ReportEntryModel(Level level, Element element, String message, String... documentationLinks) { + this(null, level, element, message, documentationLinks); + } + + private ReportEntryModel(Level level, Element element, String message, Document document, String... documentationLinks) { + this(null, level, element, message, document, documentationLinks); + } + + public ReportEntryModel(String key, Level level, Element element, String message, Document document, + String... documentationLinks) { + this(key, level, element, message, documentationLinks); try { this.filePath = new File(new URI(document.getBaseURI())).getAbsolutePath(); } catch (URISyntaxException e) { @@ -163,6 +174,10 @@ protected void printNamespace(final Writer out, final FormatStack formatStack, } }; + public String getKey() { + return key; + } + public Level getLevel() { return level; } diff --git a/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/json/JSONReport.java b/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/json/JSONReport.java index d0a30b06c..ba5dc8ebe 100644 --- a/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/json/JSONReport.java +++ b/mule-migration-tool-engine/src/main/java/com/mulesoft/tools/migration/report/json/JSONReport.java @@ -8,6 +8,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.mulesoft.tools.migration.report.html.model.ReportEntryModel; +import com.mulesoft.tools.migration.step.category.ComponentMigrationStatus; import com.mulesoft.tools.migration.step.category.MigrationReport; import java.io.File; @@ -20,9 +21,13 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkNotNull; +import static com.mulesoft.tools.migration.report.DefaultMigrationReport.getComponentKey; + +import org.jdom2.Element; /** * Generates JSON Report @@ -34,28 +39,23 @@ public class JSONReport { private final File reportDirectory; - private List reportEntries; - private Path outputProject; + private final MigrationReport report; + private final Path outputProject; - public JSONReport(List reportEntries, File reportDirectory, Path outputProject) { - this.reportEntries = reportEntries; + public JSONReport(MigrationReport report, File reportDirectory, Path outputProject) { + this.report = report; this.outputProject = outputProject; - checkNotNull(reportEntries, "Report Entries cannot be null"); + checkNotNull(report.getReportEntries(), "Report Entries cannot be null"); checkNotNull(reportDirectory, "Report directory cannot be null"); this.reportDirectory = reportDirectory; } public void printReport() { Gson gson = new GsonBuilder().setPrettyPrinting().create(); - List jsonReportModelList = - reportEntries.stream() - .map((re) -> JSONReportModel.fromReportModel(re, outputProject)) - .sorted(Comparator.comparing(JSONReportModel::getMessage)) - .sorted(Comparator.comparing(JSONReportModel::getColumnNumber)) - .sorted(Comparator.comparing(JSONReportModel::getLineNumber)) - .collect(Collectors.toList()); - String json = gson.toJson(jsonReportModelList); + + JSONReportModel jsonReportModel = new JSONReportModel(report, outputProject); + String json = gson.toJson(jsonReportModel); File file = new File(reportDirectory, "report.json"); try (OutputStreamWriter fileWriter = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) { fileWriter.append(json); @@ -69,26 +69,134 @@ public void printReport() { */ static class JSONReportModel { - private final MigrationReport.Level level; + private final String projectType; + private final String projectName; + private final List connectorsMigrated; + private final Integer numberOfMuleComponents; + private final Integer numberOfMuleComponentsMigrated; + private final Map componentDetails; + private final Integer numberOfMELExpressions; + private final Integer numberOfMELExpressionsMigrated; + private final Integer numberOfMELExpressionLines; + private final Integer numberOfMELExpressionLinesMigrated; + private final Integer numberOfDWTransformations; + private final Integer numberOfDWTransformationsMigrated; + private final Integer numberOfDWTransformationLines; + private final Integer numberOfDWTransformationLinesMigrated; + private final List detailedMessages; + + public JSONReportModel(MigrationReport report, Path outputProject) { + projectType = report.getProjectType(); + projectName = report.getProjectName(); + connectorsMigrated = report.getConnectorNames(); + numberOfMuleComponentsMigrated = report.getComponentSuccessCount(); + numberOfMuleComponents = report.getComponentFailureCount() + numberOfMuleComponentsMigrated; + componentDetails = report.getComponents(); + numberOfMELExpressionsMigrated = report.getMelExpressionsSuccessCount(); + numberOfMELExpressions = report.getMelExpressionsFailureCount() + numberOfMELExpressionsMigrated; + numberOfMELExpressionLinesMigrated = report.getMelExpressionsSuccessLineCount(); + numberOfMELExpressionLines = report.getMelExpressionsFailureLineCount() + numberOfMELExpressionLinesMigrated; + numberOfDWTransformationsMigrated = report.getDwTransformsSuccessCount(); + numberOfDWTransformations = report.getDwTransformsFailureCount() + numberOfDWTransformationsMigrated; + numberOfDWTransformationLinesMigrated = report.getDwTransformsSuccessLineCount(); + numberOfDWTransformationLines = report.getDwTransformsFailureLineCount() + numberOfDWTransformationLinesMigrated; + detailedMessages = report.getReportEntries().stream() + .map((re) -> JSONReportEntryModel.fromReportModel(re, outputProject)) + .sorted(Comparator.comparing(JSONReportEntryModel::getMessage)) + .sorted(Comparator.comparing(JSONReportEntryModel::getColumnNumber)) + .sorted(Comparator.comparing(JSONReportEntryModel::getLineNumber)) + .collect(Collectors.toList()); + } + + public String getProjectType() { + return projectType; + } + public String getProjectName() { + return projectName; + } + + public List getConnectorsMigrated() { + return connectorsMigrated; + } + + public Integer getNumberOfMuleComponents() { + return numberOfMuleComponents; + } + + public Integer getNumberOfMuleComponentsMigrated() { + return numberOfMuleComponentsMigrated; + } + + public Map getComponentDetails() { + return componentDetails; + } + + public Integer getNumberOfMELExpressions() { + return numberOfMELExpressions; + } + + public Integer getNumberOfMELExpressionsMigrated() { + return numberOfMELExpressionsMigrated; + } + + public Integer getNumberOfMELExpressionLines() { + return numberOfMELExpressionLines; + } + + public Integer getNumberOfMELExpressionLinesMigrated() { + return numberOfMELExpressionLinesMigrated; + } + + public Integer getNumberOfDWTransformations() { + return numberOfDWTransformations; + } + + public Integer getNumberOfDWTransformationsMigrated() { + return numberOfDWTransformationsMigrated; + } + + public Integer getNumberOfDWTransformationLines() { + return numberOfDWTransformationLines; + } + + public Integer getNumberOfDWTransformationLinesMigrated() { + return numberOfDWTransformationLinesMigrated; + } + + public List getDetailedMessages() { + return detailedMessages; + } + } + + static class JSONReportEntryModel { + + private final MigrationReport.Level level; + private final String key; + private final String component; private final Integer lineNumber; private final Integer columnNumber; private final String message; private final String filePath; private final List documentationLinks = new ArrayList<>(); - public JSONReportModel(MigrationReport.Level level, Integer lineNumber, Integer columnNumber, String message, - String filePath) { + private JSONReportEntryModel(String key, MigrationReport.Level level, Element component, Integer lineNumber, + Integer columnNumber, String message, + String filePath) { + this.key = key; this.level = level; + this.component = component != null ? getComponentKey(component) : "UNKNOWN"; this.lineNumber = lineNumber; this.columnNumber = columnNumber; this.message = message; this.filePath = filePath; } - public static JSONReportModel fromReportModel(ReportEntryModel rem, Path outputFolder) { + public static JSONReportEntryModel fromReportModel(ReportEntryModel rem, Path outputFolder) { String filePath = relativizePath(rem.getFilePath(), outputFolder); - return new JSONReportModel(rem.getLevel(), rem.getLineNumber(), rem.getColumnNumber(), rem.getMessage(), filePath); + return new JSONReportEntryModel(rem.getKey(), rem.getLevel(), rem.getElement(), rem.getLineNumber(), rem.getColumnNumber(), + rem.getMessage(), + filePath); } private static String relativizePath(String filePath, Path basePath) { @@ -106,10 +214,18 @@ private static String relativizePath(String filePath, Path basePath) { return filePath; } + public String getKey() { + return key; + } + public MigrationReport.Level getLevel() { return level; } + public String getComponent() { + return component; + } + public Integer getLineNumber() { return lineNumber; } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/gateway/steps/policy/http/ErrorResponseBuilderMigrationStep.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/gateway/steps/policy/http/ErrorResponseBuilderMigrationStep.java index 275131142..a7c404c7b 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/gateway/steps/policy/http/ErrorResponseBuilderMigrationStep.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/gateway/steps/policy/http/ErrorResponseBuilderMigrationStep.java @@ -27,11 +27,6 @@ public ErrorResponseBuilderMigrationStep() { super(HTTP_NAMESPACE, ERROR_RESPONSE_BUILDER_TAG_NAME); } - @Override - public void execute(Element element, MigrationReport migrationReport) throws RuntimeException { - super.execute(element, migrationReport); - } - @Override protected String getListenerResponseStatusCode() { return HTTP_LISTENER_RESPONSE_ERROR_STATUS_CODE; diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/gateway/steps/policy/http/ResponseBuilderMigrationStep.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/gateway/steps/policy/http/ResponseBuilderMigrationStep.java index efdb0e9d6..5ddb8d9a3 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/gateway/steps/policy/http/ResponseBuilderMigrationStep.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/gateway/steps/policy/http/ResponseBuilderMigrationStep.java @@ -27,11 +27,6 @@ public ResponseBuilderMigrationStep() { super(HTTP_NAMESPACE, RESPONSE_BUILDER_TAG_NAME); } - @Override - public void execute(Element element, MigrationReport migrationReport) throws RuntimeException { - super.execute(element, migrationReport); - } - @Override protected String getListenerResponseStatusCode() { return HTTP_LISTENER_RESPONSE_SUCCESS_STATUS_CODE; diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/ExpressionComponent.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/ExpressionComponent.java index cff673891..7b561ead5 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/ExpressionComponent.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/ExpressionComponent.java @@ -34,5 +34,6 @@ public ExpressionComponent() { @Override public void execute(Element object, MigrationReport report) throws RuntimeException { report.report("components.unsupported", object, object, "expression-component"); + report.addComponentFailure(object); } } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/KeepElementsAtBottomOfFlow.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/KeepElementsAtBottomOfFlow.java index 2fd083577..656191371 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/KeepElementsAtBottomOfFlow.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/KeepElementsAtBottomOfFlow.java @@ -47,4 +47,9 @@ public void execute(Element element, MigrationReport report) throws RuntimeExcep element.detach(); addElementToBottom(flow, element); } + + @Override + public boolean shouldReportMetrics() { + return false; + } } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/PreprocessNamespaces.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/PreprocessNamespaces.java index 4d4de92ee..e237cf554 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/PreprocessNamespaces.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/PreprocessNamespaces.java @@ -59,6 +59,7 @@ public void addReportEntries(Document document, MigrationReport report, Applicat } else { report.report("components.unknown", node, node, ns.getPrefix(), ns.getURI(), ADDITIONAL_SPRING_NAMESPACES_PROP); } + report.addComponentFailure(node); }); }); diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemoveMetadataAttributes.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemoveMetadataAttributes.java index 2fd0ba389..8bd44e48f 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemoveMetadataAttributes.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemoveMetadataAttributes.java @@ -44,4 +44,9 @@ public void execute(Element element, MigrationReport report) throws RuntimeExcep .forEach(att -> att.detach()); element.removeNamespaceDeclaration(METADATA_NAMESPACE); } + + @Override + public boolean shouldReportMetrics() { + return false; + } } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemoveSyntheticMigrationAttributes.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemoveSyntheticMigrationAttributes.java index 218f60656..b0ce24940 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemoveSyntheticMigrationAttributes.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/core/RemoveSyntheticMigrationAttributes.java @@ -42,4 +42,10 @@ public void execute(Element element, MigrationReport report) throws RuntimeExcep .forEach(att -> att.detach()); element.removeNamespaceDeclaration(MIGRATION_NAMESPACE); } + + @Override + public boolean shouldReportMetrics() { + return false; + } + } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/ee/EETransform.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/ee/EETransform.java index 16f471e9c..887dbb3a9 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/ee/EETransform.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/ee/EETransform.java @@ -161,13 +161,16 @@ private void addOutboundProperty(Element element, MigrationReport report) { } private void migrateDWScript(Element element, MigrationReport report) { - if (!StringUtils.isEmpty(element.getText())) { + String sourceScript = element.getText(); + if (!StringUtils.isEmpty(sourceScript)) { try { - String migratedScript = migrateDWToV2(element.getText()); + String migratedScript = migrateDWToV2(sourceScript); element.removeContent(); setText(element, migratedScript); + report.dwTransformsSuccess(sourceScript); } catch (Exception ex) { - report.report("dataWeave.migrationErrorScript", element, element, element.getText(), ex.getMessage()); + report.report("dataWeave.migrationErrorScript", element, element, sourceScript, ex.getMessage()); + report.dwTransformsFailure(sourceScript); } } else if (element.getAttribute("resource") != null) { Attribute resourceAttr = element.getAttribute("resource"); diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/ee/MigrateDWScriptFiles.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/ee/MigrateDWScriptFiles.java index 35db4088d..00d9c79f3 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/ee/MigrateDWScriptFiles.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/mule/steps/ee/MigrateDWScriptFiles.java @@ -36,19 +36,22 @@ public void execute(Path basePath, MigrationReport report) throws RuntimeExcepti List dwFiles = (List) FileUtils.listFiles(basePath.toFile(), extensions, true); dwFiles.forEach(f -> { try { - migrateFile(f); + migrateFile(f, report); } catch (Exception ex) { report.report("dataWeave.migrationErrorFile", null, null, f.getPath(), ex.getMessage()); } }); } - private void migrateFile(File file) { + private void migrateFile(File file, MigrationReport report) { + String dwScript = null; try { - String dwScript = new String(Files.readAllBytes(file.toPath())); + dwScript = new String(Files.readAllBytes(file.toPath())); dwScript = migrateDWToV2(dwScript); Files.write(file.toPath(), dwScript.getBytes()); + report.dwTransformsSuccess(dwScript); } catch (Exception ex) { + report.dwTransformsFailure(dwScript == null ? String.format("Error trying to read script %s -- %s", file, ex) : dwScript); throw new RuntimeException(ex); } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/MelToDwExpressionMigrator.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/MelToDwExpressionMigrator.java index 6c727b971..42d34e14f 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/MelToDwExpressionMigrator.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/MelToDwExpressionMigrator.java @@ -23,6 +23,8 @@ import org.apache.commons.lang3.StringUtils; import org.jdom2.Element; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import scala.collection.JavaConverters; import java.util.Arrays; @@ -40,6 +42,8 @@ */ public class MelToDwExpressionMigrator implements ExpressionMigrator { + private static Logger logger = LoggerFactory.getLogger(MelToDwExpressionMigrator.class); + private final MigrationReport report; private final Pattern EXPRESSION_WRAPPER = Pattern.compile("^\\s*#\\[(.*)]\\s*$", Pattern.DOTALL); @@ -84,6 +88,8 @@ public String migrateExpression(String originalExpression, boolean dataWeaveBody public String translateSingleExpression(String unwrappedExpression, boolean dataWeaveBodyOnly, Element element, boolean enricher) { + logger.debug(" --->> Evaluating MEL expression at element {} -> {}", element != null ? element.getName() : "null", + unwrappedExpression); String migratedExpression; MigrationResult result; try { @@ -125,6 +131,7 @@ public String translateSingleExpression(String unwrappedExpression, boolean data migratedExpression = migratedExpression.replaceFirst("%dw 2\\.0\n---", "").trim(); } + report.melExpressionSuccess(unwrappedExpression); return escapeUnderscores(migratedExpression); } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/DefaultMelCompatibilityResolver.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/DefaultMelCompatibilityResolver.java index a249dfe57..2d7269848 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/DefaultMelCompatibilityResolver.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/DefaultMelCompatibilityResolver.java @@ -29,7 +29,7 @@ public boolean canResolve(String original) { public String resolve(String original, Element element, MigrationReport report, ApplicationModel model, ExpressionMigrator expressionMigrator) { report.report("expressions.melToDw", element, element); - + report.melExpressionFailure(original); return "mel:" + original; } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/Encode64Resolver.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/Encode64Resolver.java index 6ae397a90..0607324a2 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/Encode64Resolver.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/Encode64Resolver.java @@ -44,11 +44,13 @@ public String resolve(String original, Element element, MigrationReport report, innerExpression = ((MelToDwExpressionMigrator) expressionMigrator).translateSingleExpression(innerExpression, true, element, false); if (!innerExpression.startsWith("mel:")) { + report.melExpressionSuccess(original); return "dw::core::Binaries::toBase64(" + innerExpression + ")"; } } } report.report("expressions.encodeBase64", element, element); + report.melExpressionFailure(original); return original; } } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/FunctionExpressionEvaluatorResolver.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/FunctionExpressionEvaluatorResolver.java index 1f52b196a..a1f95fcca 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/FunctionExpressionEvaluatorResolver.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/FunctionExpressionEvaluatorResolver.java @@ -42,6 +42,7 @@ public boolean canResolve(String original) { public String resolve(String original, Element element, MigrationReport report, ApplicationModel model, ExpressionMigrator expressionMigrator) { String functionName = getFunctionName(original); + report.melExpressionSuccess(original); if (NOW_FUNCTION.equalsIgnoreCase(functionName) || DATE_FUNCTION.equalsIgnoreCase(functionName)) { return "now()"; diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InboundAttachmentsCompatibilityResolver.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InboundAttachmentsCompatibilityResolver.java index 49a808948..10f0a91a4 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InboundAttachmentsCompatibilityResolver.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InboundAttachmentsCompatibilityResolver.java @@ -29,7 +29,7 @@ public boolean canResolve(String original) { public String resolve(String original, Element element, MigrationReport report, ApplicationModel model, ExpressionMigrator expressionMigrator) { report.report("expressions.inboundAttachments", element, element); - + report.melExpressionFailure(original); return "mel:" + original; } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InboundPropertiesCompatibilityResolver.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InboundPropertiesCompatibilityResolver.java index 6805d4a9c..426049bf9 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InboundPropertiesCompatibilityResolver.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InboundPropertiesCompatibilityResolver.java @@ -30,6 +30,7 @@ public boolean canResolve(String original) { public String resolve(String original, Element element, MigrationReport report, ApplicationModel model, ExpressionMigrator expressionMigrator) { String propertyName = original.trim().replaceFirst("(?i)^header:inbound:", EMPTY); + report.melExpressionSuccess(original); return "vars.compatibility_inboundProperties." + propertyName; } } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InvocationPropertiesCompatibilityResolver.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InvocationPropertiesCompatibilityResolver.java index 37085639b..20c974b87 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InvocationPropertiesCompatibilityResolver.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/InvocationPropertiesCompatibilityResolver.java @@ -30,6 +30,7 @@ public boolean canResolve(String original) { public String resolve(String original, Element element, MigrationReport report, ApplicationModel model, ExpressionMigrator expressionMigrator) { String sessionVarName = original.trim().replaceFirst("(?i)^header:invocation:", EMPTY); + report.melExpressionSuccess(original); return "vars." + sessionVarName; } } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/OutboundPropertiesCompatibilityResolver.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/OutboundPropertiesCompatibilityResolver.java index 249df8506..699328472 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/OutboundPropertiesCompatibilityResolver.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/OutboundPropertiesCompatibilityResolver.java @@ -32,13 +32,13 @@ public boolean canResolve(String original) { @Override public String resolve(String original, Element element, MigrationReport report, ApplicationModel model, ExpressionMigrator expressionMigrator) { - return doResolve(original); + return doResolve(original, report); } @Override public String resolve(String original, Element element, MigrationReport report, ApplicationModel model, ExpressionMigrator expressionMigrator, boolean enricher) { - String propertyName = doResolve(original); + String propertyName = doResolve(original, report); if (enricher) { return propertyName; } else { @@ -46,7 +46,8 @@ public String resolve(String original, Element element, MigrationReport report, } } - private String doResolve(String original) { + private String doResolve(String original, MigrationReport report) { + report.melExpressionSuccess(original); return original.trim().replaceFirst("(?i)^(header:outbound:|header:)", EMPTY); } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/SessionVariablesCompatibilityResolver.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/SessionVariablesCompatibilityResolver.java index f669d7d36..dbf1869ae 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/SessionVariablesCompatibilityResolver.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/SessionVariablesCompatibilityResolver.java @@ -30,6 +30,7 @@ public boolean canResolve(String original) { public String resolve(String original, Element element, MigrationReport report, ApplicationModel model, ExpressionMigrator expressionMigrator) { String sessionVarName = original.trim().replaceFirst("(?i)^header:session:", EMPTY); + report.melExpressionSuccess(original); return "vars.compatibility_sessionVars." + sessionVarName; } } diff --git a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/VariablesCompatibilityResolver.java b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/VariablesCompatibilityResolver.java index c004423ae..cdf050b3c 100644 --- a/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/VariablesCompatibilityResolver.java +++ b/mule-migration-tool-library/src/main/java/com/mulesoft/tools/migration/library/tools/mel/VariablesCompatibilityResolver.java @@ -31,6 +31,7 @@ public boolean canResolve(String original) { public String resolve(String original, Element element, MigrationReport report, ApplicationModel model, ExpressionMigrator expressionMigrator) { String varName = original.trim().replaceFirst("(?i)^variable:", EMPTY); + report.melExpressionSuccess(original); return "vars." + varName; } } diff --git a/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/gateway/steps/throttling/FixedTimeAlgorithmMigrationStepTestCase.java b/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/gateway/steps/throttling/FixedTimeAlgorithmMigrationStepTestCase.java index e1b08e654..ada5dd909 100644 --- a/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/gateway/steps/throttling/FixedTimeAlgorithmMigrationStepTestCase.java +++ b/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/gateway/steps/throttling/FixedTimeAlgorithmMigrationStepTestCase.java @@ -149,7 +149,6 @@ public void oneRateLimitElement() { assertOperationElements(element, 1, true); assertNamespaces(element); assertPolicyName(element); - verifyNoMoreInteractions(reportMock); } @Test @@ -164,7 +163,6 @@ public void multipleRateLimitElements() { assertOperationElements(element, 2, true); assertNamespaces(element); assertPolicyName(element); - verifyNoMoreInteractions(reportMock); } @Test @@ -179,7 +177,6 @@ public void oneRateLimitElementSpikeControl() { assertOperationElements(element, 1, false); assertNamespaces(element); assertPolicyName(element); - verifyNoMoreInteractions(reportMock); } @Test @@ -195,7 +192,6 @@ public void multipleRateLimitElementsSpikeControl() { assertNamespaces(element); verify(reportMock).report("throttling.throttlingMultipleTiersNotSupported", element, element); assertPolicyName(element); - verifyNoMoreInteractions(reportMock); } @Test diff --git a/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/gateway/steps/throttling/SlaBasedAlgorithmMigrationStepTestCase.java b/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/gateway/steps/throttling/SlaBasedAlgorithmMigrationStepTestCase.java index a3a1bc7d1..6f5efac95 100644 --- a/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/gateway/steps/throttling/SlaBasedAlgorithmMigrationStepTestCase.java +++ b/mule-migration-tool-library/src/test/java/com/mulesoft/tools/migration/library/gateway/steps/throttling/SlaBasedAlgorithmMigrationStepTestCase.java @@ -163,7 +163,6 @@ public void oneRateLimitSLAElement() { assertOperationElements(element, 1, true); assertNamespaces(element); assertPolicyName(element); - verifyNoMoreInteractions(reportMock); } @Test @@ -178,7 +177,6 @@ public void multipleRateLimitSLAElements() { assertOperationElements(element, 2, true); assertNamespaces(element); assertPolicyName(element); - verifyNoMoreInteractions(reportMock); } @Test @@ -194,7 +192,6 @@ public void oneRateLimitSLAElementSpikeControl() { assertNamespaces(element); verify(reportMock).report("throttling.throttlingSLANotSupported", element.getParentElement(), element.getParentElement()); assertPolicyName(element); - verifyNoMoreInteractions(reportMock); } @Test @@ -210,7 +207,6 @@ public void multipleRateLimitSLAElementsSpikeControl() { assertNamespaces(element); verify(reportMock).report("throttling.throttlingSLANotSupported", element.getParentElement(), element.getParentElement()); assertPolicyName(element); - verifyNoMoreInteractions(reportMock); } @Test diff --git a/pom.xml b/pom.xml index 9b6697c0e..382b08bb3 100644 --- a/pom.xml +++ b/pom.xml @@ -140,7 +140,7 @@ 2.0.2 1.8 - 2.12.7 + 2.12.9 2.1.4 3.0.1 @@ -437,36 +437,35 @@ maven-deploy-plugin ${maven.deploy.plugin.version} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + org.codehaus.gmavenplus + gmavenplus-plugin + 1.13.1 + + + execute + + execute + + + + + + + + + + + org.codehaus.groovy + groovy-all + 3.0.9 + pom + runtime + + + + diff --git a/runner/src/main/java/com/mulesoft/tools/migration/MigrationRunner.java b/runner/src/main/java/com/mulesoft/tools/migration/MigrationRunner.java index 29ce60716..b3dfee6dc 100644 --- a/runner/src/main/java/com/mulesoft/tools/migration/MigrationRunner.java +++ b/runner/src/main/java/com/mulesoft/tools/migration/MigrationRunner.java @@ -44,7 +44,7 @@ public class MigrationRunner { private final static String CANCEL_ON_ERROR = "cancelOnError"; private final static String PROJECT_PARENT_GAV = "projectParentGAV"; private final static String PROJECT_GAV = "projectGAV"; - public static final String JSON_REPORT_PROP_NAME = "jsonReport"; + public static final String JSON_REPORT = "jsonReport"; private String projectBasePath; private String parentDomainProjectBasePath; @@ -53,6 +53,7 @@ public class MigrationRunner { private boolean cancelOnError = false; private Parent projectParentGAV; private String projectGAV; + private boolean jsonReport; private String userId; @@ -108,7 +109,7 @@ private MigrationJob buildMigrationJob() throws Exception { .withCancelOnError(cancelOnError) .withProjectParentGAV(projectParentGAV) .withProjectGAV(projectGAV) - .withJsonReport(Boolean.getBoolean(JSON_REPORT_PROP_NAME)) + .withJsonReport(jsonReport) .build(); } @@ -130,6 +131,7 @@ private boolean initializeOptions(String[] args) { options.addOption(CANCEL_ON_ERROR, true, "Use cancelOnError to stop the migration. Default is false"); options.addOption(PROJECT_PARENT_GAV, true, "Use projectParentGAV to migration parent in your pom.xml"); options.addOption(PROJECT_GAV, true, "Use projectGAV to override default GAV coordinates when a pom.xml is not provided"); + options.addOption(JSON_REPORT, false, "Generate migration report in JSON format"); options.addOption("userId", true, "The userId to send for the usage statistics"); options.addOption("sessionId", true, "The sessionId to send for the usage statistics"); @@ -197,6 +199,10 @@ private boolean initializeOptions(String[] args) { } } + if (line.hasOption(JSON_REPORT)) { + jsonReport = true; + } + if (line.hasOption(HELP)) { printHelp(options); } diff --git a/scripts/update-e2e-tests-output.groovy b/scripts/update-e2e-tests-output.groovy new file mode 100644 index 000000000..eaad26cda --- /dev/null +++ b/scripts/update-e2e-tests-output.groovy @@ -0,0 +1,39 @@ +import java.nio.file.Files +import java.nio.file.Paths; + +import static groovy.io.FileType.FILES +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING + +println "----------------------------" +println "Overwriting e2e tests output" +println "----------------------------" + +def actualOutputPath = Paths.get("mule-migration-tool-e2e-tests/target/apps") +def expectedOutputPath = Paths.get("mule-migration-tool-e2e-tests/src/test/resources/e2e") + +if (!actualOutputPath.toFile().exists()) { + println "Run e2e tests before trying to update the tests output files" + return +} + +def sourceFiles = [] +actualOutputPath.eachFileRecurse(FILES) { + sourceFiles.add(it) +} + +expectedOutputPath.eachFileRecurse(FILES) { + if (it.toString().contains("/output/")) { + def rel = expectedOutputPath.relativize(it) + def source = findSourceFile(sourceFiles, rel.toString().replace("/output/", "/")) + if (source != null) { + println "Copying $source to $it" + Files.copy(source, it, REPLACE_EXISTING) + } else { + println "[WARNING] Source file not found for $it" + } + } +} + +static def findSourceFile(sources, target) { + return sources.find { it.endsWith(target) } +}