Search in sources :

Example 26 with PomModel

use of com.mulesoft.tools.migration.project.model.pom.PomModel 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 27 with PomModel

use of com.mulesoft.tools.migration.project.model.pom.PomModel in project mule-migration-assistant by mulesoft.

the class ThrottlingWithFileRenameMigrationTestCase method assertPomModel.

private void assertPomModel() {
    PomModel pomModel = appModel.getPomModel().get();
    assertThat(pomModel.getDependencies().size(), is(2));
    Dependency httpTransformDependency = pomModel.getDependencies().get(0);
    assertThat(httpTransformDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(httpTransformDependency.getArtifactId(), is(MULE_HTTP_POLICY_TRANSFORM_EXTENSION_ARTIFACT_ID));
    assertThat(httpTransformDependency.getVersion(), is(notNullValue()));
    assertThat(httpTransformDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
    Dependency policyTransformExtensionDependency = pomModel.getDependencies().get(1);
    assertThat(policyTransformExtensionDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(policyTransformExtensionDependency.getArtifactId(), is(MULE_THROTTLING_EXTENSION_ARTIFACT_ID));
    assertThat(policyTransformExtensionDependency.getVersion(), is(notNullValue()));
    assertThat(policyTransformExtensionDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
    assertPomDeployProperties(pomModel);
}
Also used : PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency)

Example 28 with PomModel

use of com.mulesoft.tools.migration.project.model.pom.PomModel 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 29 with PomModel

use of com.mulesoft.tools.migration.project.model.pom.PomModel in project mule-migration-assistant by mulesoft.

the class ProxyRequestHeadersProcessorMigrationStepTestCase method customProcessorPomContributionTest.

@Test
public void customProcessorPomContributionTest() throws Exception {
    final ProxyResponseHeadersProcessorMigrationStep step = new ProxyResponseHeadersProcessorMigrationStep();
    step.setApplicationModel(appModel);
    step.execute(appModel.getNode(XPATH_NODE_EXPRESSION), reportMock);
    PomModel pm = appModel.getPomModel().get();
    assertThat(pm.getDependencies().size(), is(1));
    Dependency customProcessorDependency = pm.getDependencies().get(0);
    assertThat(customProcessorDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(customProcessorDependency.getArtifactId(), is(MULE_HTTP_PROXY_EXTENSION_ARTIFACT_ID));
    assertThat(customProcessorDependency.getVersion(), is(notNullValue()));
    assertThat(customProcessorDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
}
Also used : PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Test(org.junit.Test)

Example 30 with PomModel

use of com.mulesoft.tools.migration.project.model.pom.PomModel in project mule-migration-assistant by mulesoft.

the class ProxyRequestHeadersProcessorMigrationStepTestCase method migrateElementAndPomTest.

@Test
public void migrateElementAndPomTest() throws Exception {
    final ProxyRequestHeadersProcessorMigrationStep step = new ProxyRequestHeadersProcessorMigrationStep();
    Element element = appModel.getNode(XPATH_NODE_EXPRESSION);
    step.setApplicationModel(appModel);
    step.execute(element, reportMock);
    assertThat(element.getName(), is(REQUEST_HEADERS));
    assertThat(element.getNamespace(), is(PROXY_NAMESPACE));
    assertThat(element.getAttributes().size(), is(2));
    assertThat(element.getAttribute(CONFIG_REF).getValue(), is(PROXY_CONFIG));
    assertThat(element.getAttribute(TARGET).getValue(), is(PROXY_REQUEST_HEADERS));
    assertThat(element.getContent().size(), is(0));
    assertConfigElement(element);
    PomModel pm = appModel.getPomModel().get();
    assertThat(pm.getDependencies().size(), is(1));
    Dependency customProcessorDependency = pm.getDependencies().get(0);
    assertThat(customProcessorDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(customProcessorDependency.getArtifactId(), is(MULE_HTTP_PROXY_EXTENSION_ARTIFACT_ID));
    assertThat(customProcessorDependency.getVersion(), is(notNullValue()));
    assertThat(customProcessorDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
}
Also used : Element(org.jdom2.Element) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Test(org.junit.Test)

Aggregations

PomModel (com.mulesoft.tools.migration.project.model.pom.PomModel)34 Dependency (com.mulesoft.tools.migration.project.model.pom.Dependency)24 Test (org.junit.Test)24 Element (org.jdom2.Element)10 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)9 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)6 Path (java.nio.file.Path)4 XMLOutputter (org.jdom2.output.XMLOutputter)3 Parent (com.mulesoft.tools.migration.project.model.pom.Parent)2 Plugin (com.mulesoft.tools.migration.project.model.pom.Plugin)2 ExpressionMigrator (com.mulesoft.tools.migration.util.ExpressionMigrator)2 List (java.util.List)2 StringUtils (org.apache.commons.lang3.StringUtils)2 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 MigrationAbortException (com.mulesoft.tools.migration.exception.MigrationAbortException)1 MigrationStepException (com.mulesoft.tools.migration.exception.MigrationStepException)1 MigrationTaskException (com.mulesoft.tools.migration.exception.MigrationTaskException)1