Search in sources :

Example 31 with MigrationReport

use of com.mulesoft.tools.migration.step.category.MigrationReport in project mule-migration-assistant by mulesoft.

the class UpdateMuleMavenPlugin method execute.

@Override
public void execute(PomModel pomModel, MigrationReport report) throws RuntimeException {
    String packagingType = pomModel.getPackaging();
    if (StringUtils.equals(packagingType, MULE_APPLICATION_3_PACKAGING_TYPE)) {
        pomModel.setPackaging(MULE_APPLICATION_4_PACKAGING_TYPE);
    }
    Plugin muleMavenPlugin = pomModel.removePlugin(p -> p.getArtifactId().equals(MULE_MAVEN_PLUGIN_ARTIFACT_ID)).orElse(buildMule4MuleMavenPluginConfiguration());
    muleMavenPlugin.setVersion(MULE_MAVEN_PLUGIN_VERSION);
    muleMavenPlugin.setExtensions("true");
    Xpp3Dom configuration = muleMavenPlugin.getConfiguration();
    if (configuration != null) {
        updateDeploymentConfiguration(configuration);
    }
    pomModel.addPlugin(muleMavenPlugin);
}
Also used : IntStream.range(java.util.stream.IntStream.range) PomContribution(com.mulesoft.tools.migration.step.category.PomContribution) Set(java.util.Set) MULE_APPLICATION_4_PACKAGING_TYPE(com.mulesoft.tools.migration.project.model.pom.PomModelUtils.MULE_APPLICATION_4_PACKAGING_TYPE) MULE_MAVEN_PLUGIN_ARTIFACT_ID(com.mulesoft.tools.migration.project.model.pom.PomModelUtils.MULE_MAVEN_PLUGIN_ARTIFACT_ID) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) MULE_MAVEN_PLUGIN_VERSION(com.mulesoft.tools.migration.project.model.pom.PomModelUtils.MULE_MAVEN_PLUGIN_VERSION) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) StringUtils(org.apache.commons.lang3.StringUtils) OptionalInt(java.util.OptionalInt) HashSet(java.util.HashSet) MULE_APPLICATION_3_PACKAGING_TYPE(com.mulesoft.tools.migration.project.model.pom.PomModelUtils.MULE_APPLICATION_3_PACKAGING_TYPE) PomModelUtils.buildMule4MuleMavenPluginConfiguration(com.mulesoft.tools.migration.project.model.pom.PomModelUtils.buildMule4MuleMavenPluginConfiguration) Plugin(com.mulesoft.tools.migration.project.model.pom.Plugin) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Plugin(com.mulesoft.tools.migration.project.model.pom.Plugin)

Example 32 with MigrationReport

use of com.mulesoft.tools.migration.step.category.MigrationReport in project mule-migration-assistant by mulesoft.

the class FederationPomContributionMigrationStepTestCase method pomContributionTest.

@Test
public void pomContributionTest() {
    MigrationReport reportMock = reportMock = mock(MigrationReport.class);
    PomModel pm = new PomModel();
    FederationPomContributionMigrationStep step = new FederationPomContributionMigrationStep();
    step.execute(pm, reportMock);
    assertThat(pm.getDependencies().size(), is(2));
    Dependency httpPolicyTransformExtension = pm.getDependencies().get(0);
    assertThat(httpPolicyTransformExtension.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(httpPolicyTransformExtension.getArtifactId(), is(MULE_HTTP_POLICY_TRANSFORM_EXTENSION_ARTIFACT_ID));
    assertThat(httpPolicyTransformExtension.getVersion(), is(notNullValue()));
    assertThat(httpPolicyTransformExtension.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
    Dependency federationExtensionDependency = pm.getDependencies().get(1);
    assertThat(federationExtensionDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(federationExtensionDependency.getArtifactId(), is(MULE_FEDERATION_EXTENSION_ARTIFACT_ID));
    assertThat(federationExtensionDependency.getVersion(), is(notNullValue()));
    assertThat(federationExtensionDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
}
Also used : FederationPomContributionMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.federation.FederationPomContributionMigrationStep) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Test(org.junit.Test)

Example 33 with MigrationReport

use of com.mulesoft.tools.migration.step.category.MigrationReport in project mule-migration-assistant by mulesoft.

the class PolicyFileRenameMigrationStepTestCase method renameTest.

@Test
public void renameTest() throws Exception {
    MigrationReport migrationReport = mock(MigrationReport.class);
    ApplicationModel.ApplicationModelBuilder amb = new ApplicationModel.ApplicationModelBuilder();
    amb.withProjectType(ProjectType.MULE_THREE_POLICY);
    amb.withConfigurationFiles(Arrays.asList(APPLICATION_MODEL_PATH.resolve("src/main/mule/simple-test-policy.xml")));
    amb.withProjectBasePath(APPLICATION_MODEL_PATH);
    appModel = amb.build();
    PolicyFileRenameMigrationStep step = new PolicyFileRenameMigrationStep();
    step.setApplicationModel(appModel);
    step.execute(APPLICATION_MODEL_PATH, migrationReport);
    assertThat(APPLICATION_MODEL_PATH.resolve(appModel.getPomModel().get().getArtifactId() + ".yaml").toFile().exists(), is(true));
    assertThat(APPLICATION_MODEL_PATH.resolve("simple-test-policy.yaml").toFile().exists(), is(false));
    Path sourcesFilePath = APPLICATION_MODEL_PATH.resolve("src/main/mule");
    assertThat(sourcesFilePath.resolve("template.xml").toFile().exists(), is(true));
    assertThat(sourcesFilePath.resolve("simple-test-policy.xml").toFile().exists(), is(false));
    assertThat(appModel.getApplicationDocuments().size(), is(1));
    assertThat(appModel.getApplicationDocuments().get(Paths.get("src/main/mule/template.xml")), notNullValue());
    assertThat(appModel.getApplicationDocuments().get(Paths.get("src/main/mule/simple-test-policy.xml")), nullValue());
}
Also used : Path(java.nio.file.Path) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) PolicyFileRenameMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.basicstructure.PolicyFileRenameMigrationStep) Test(org.junit.Test)

Aggregations

MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)33 Element (org.jdom2.Element)28 Optional (java.util.Optional)16 Namespace (org.jdom2.Namespace)16 CORE_NAMESPACE (com.mulesoft.tools.migration.step.util.XmlDslUtils.CORE_NAMESPACE)13 List (java.util.List)13 ExpressionMigratorAware (com.mulesoft.tools.migration.step.ExpressionMigratorAware)12 ExpressionMigrator (com.mulesoft.tools.migration.util.ExpressionMigrator)12 Attribute (org.jdom2.Attribute)12 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)11 AbstractApplicationModelMigrationStep (com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep)11 TransportsUtils.processAddress (com.mulesoft.tools.migration.step.util.TransportsUtils.processAddress)10 XmlDslUtils.copyAttributeIfPresent (com.mulesoft.tools.migration.step.util.XmlDslUtils.copyAttributeIfPresent)9 XmlDslUtils.addElementAfter (com.mulesoft.tools.migration.step.util.XmlDslUtils.addElementAfter)8 Collectors.toList (java.util.stream.Collectors.toList)8 XmlDslUtils.addTopLevelElement (com.mulesoft.tools.migration.step.util.XmlDslUtils.addTopLevelElement)7 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)6 TransportsUtils.migrateOutboundEndpointStructure (com.mulesoft.tools.migration.step.util.TransportsUtils.migrateOutboundEndpointStructure)6 XmlDslUtils.addMigrationAttributeToElement (com.mulesoft.tools.migration.step.util.XmlDslUtils.addMigrationAttributeToElement)6 StringUtils (org.apache.commons.lang3.StringUtils)6