Search in sources :

Example 16 with PomModel

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

the class ThreatProtectionMigrationTaskTestCase method assertPomModel.

private void assertPomModel(boolean isXmlThreatProtection) {
    PomModel pomModel = appModel.getPomModel().get();
    Dependency threatProtectionDependency;
    if (isXmlThreatProtection) {
        assertThat(pomModel.getDependencies().size(), is(3));
        threatProtectionDependency = pomModel.getDependencies().get(2);
        assertThat(threatProtectionDependency.getArtifactId(), is(MULE_XML_THREAT_PROTECTION_EXTENSION_ARTIFACT_ID));
    } else {
        assertThat(pomModel.getDependencies().size(), is(2));
        threatProtectionDependency = pomModel.getDependencies().get(1);
        assertThat(threatProtectionDependency.getArtifactId(), is(MULE_JSON_THREAT_PROTECTION_EXTENSION_ARTIFACT_ID));
    }
    assertThat(threatProtectionDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(threatProtectionDependency.getVersion(), is(notNullValue()));
    assertThat(threatProtectionDependency.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)

Example 17 with PomModel

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

the class ThrottlingMigrationTaskTestCase 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));
}
Also used : PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency)

Example 18 with PomModel

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

the class PolicyDeployPropertiesPomContributionMigrationStepTestCase method pomDeployPropertiesTest.

@Test
public void pomDeployPropertiesTest() {
    PomModel pomModel = new PomModel();
    PolicyDeployPropertiesPomContributionMigrationStep step = new PolicyDeployPropertiesPomContributionMigrationStep();
    step.execute(pomModel, mock(MigrationReport.class));
    assertThat(pomModel.getGroupId(), is(GROUP_ID_VALUE));
    Properties pomProperties = pomModel.getProperties();
    assertNotNull(pomProperties);
    assertThat(pomProperties.size(), is(2));
    assertThat(pomProperties.getProperty(EXCHANGE_URL_KEY), is(EXCHANGE_URL_VALUE));
    assertThat(pomProperties.getProperty(MULE_MAVEN_PLUGIN_VERSION_KEY), is(notNullValue()));
    List<Repository> repositoryList = pomModel.getRepositories();
    assertThat(repositoryList.size(), is(1));
    Repository repository = repositoryList.get(0);
    assertThat(repository.getId(), is(EXCHANGE_SERVER_ID));
    assertThat(repository.getName(), is(EXCHANGE_SERVER_NAME));
    assertThat(repository.getUrl(), is(EXCHANGE_SERVER_URL));
    assertThat(repository.areSnapshotsEnabled(), is(true));
    DeploymentRepository deploymentRepository = pomModel.getMavenModelCopy().getDistributionManagement().getRepository();
    assertNotNull(deploymentRepository);
    assertThat(deploymentRepository.getId(), is(EXCHANGE_SERVER_ID));
    assertThat(deploymentRepository.getName(), is(DISTRIBUTION_MANAGEMENT_REPOSITORY_NAME));
    assertThat(deploymentRepository.getUrl(), is(EXCHANGE_SERVER_URL));
    assertThat(deploymentRepository.getLayout(), is(DISTRIBUTION_MANAGEMENT_LAYOUT));
    List<Plugin> pluginList = pomModel.getPlugins();
    assertThat(pluginList.size(), is(2));
    Plugin muleMavenPlugin = pluginList.get(0);
    assertThat(muleMavenPlugin.getGroupId(), is(MULE_MAVEN_PLUGIN_GROUP_ID));
    assertThat(muleMavenPlugin.getArtifactId(), is(MULE_MAVEN_PLUGIN_ARTIFACT_ID));
    assertThat(muleMavenPlugin.getVersion(), is(MULE_MAVEN_PLUGIN_VERSION));
    assertThat(muleMavenPlugin.getExtensions(), is(MULE_MAVEN_PLUGIN_EXTENSIONS));
    Plugin mavenDeployPlugin = pluginList.get(1);
    assertThat(mavenDeployPlugin.getGroupId(), is(MAVEN_DEPLOY_PLUGIN_GROUP_ID));
    assertThat(mavenDeployPlugin.getArtifactId(), is(MAVEN_DEPLOY_PLUGIN_ARTIFACT_ID));
    List<PluginExecution> pluginExecutionList = mavenDeployPlugin.getExecutions();
    assertThat(pluginExecutionList.size(), is(1));
    PluginExecution pluginExecution = pluginExecutionList.get(0);
    assertThat(pluginExecution.getId(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_ID));
    assertThat(pluginExecution.getPhase(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_PHASE));
    assertThat(pluginExecution.getGoals().get(0), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_GOAL));
    Xpp3Dom configuration = pluginExecution.getConfiguration();
    assertThat(configuration.getChild(REPOSITORY_ID_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_REPOSITORY_ID));
    assertThat(configuration.getChild(URL_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_URL));
    assertThat(configuration.getChild(FILE_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_FILE));
    assertThat(configuration.getChild(GENERATE_POM_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_GENERATE_POM));
    assertThat(configuration.getChild(GROUP_ID_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_GROUP_ID));
    assertThat(configuration.getChild(ARTIFACT_ID_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_ARTIFACT_ID));
    assertThat(configuration.getChild(VERSION_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_VERSION));
    assertThat(configuration.getChild(PACKAGING_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_PACKAGING));
    assertThat(configuration.getChild(CLASSIFIER_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_CLASSIFIER));
    List<Repository> pluginRepositoriesList = pomModel.getPluginRepositories();
    assertThat(pluginRepositoriesList.size(), is(1));
    Repository pluginRepository = pluginRepositoriesList.get(0);
    assertThat(pluginRepository.getId(), is(MULE_PLUGIN_CLASSIFIER));
    assertThat(pluginRepository.getName(), is(PLUGIN_REPOSITORY_NAME));
    assertThat(pluginRepository.getUrl(), is(PLUGIN_REPOSITORY_URL));
}
Also used : PluginExecution(com.mulesoft.tools.migration.project.model.pom.PluginExecution) Repository(com.mulesoft.tools.migration.project.model.pom.Repository) DeploymentRepository(org.apache.maven.model.DeploymentRepository) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) PolicyDeployPropertiesPomContributionMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.utils.PolicyDeployPropertiesPomContributionMigrationStep) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) DeploymentRepository(org.apache.maven.model.DeploymentRepository) Properties(java.util.Properties) Plugin(com.mulesoft.tools.migration.project.model.pom.Plugin) Test(org.junit.Test)

Example 19 with PomModel

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

the class XmlPolicyTagMigrationStepTestCase method xmlPomContributionTest.

@Test
public void xmlPomContributionTest() {
    XmlPolicyTagMigrationStep step = new XmlPolicyTagMigrationStep();
    step.setApplicationModel(appModel);
    Element element = appModel.getNode(XPATH_NODE_EXPRESSION);
    step.execute(element, reportMock);
    PomModel pm = appModel.getPomModel().get();
    assertThat(pm.getDependencies().size(), is(1));
    Dependency xmlThreatProtectionDependency = pm.getDependencies().get(0);
    assertThat(xmlThreatProtectionDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(xmlThreatProtectionDependency.getArtifactId(), is(MULE_XML_THREAT_PROTECTION_EXTENSION_ARTIFACT_ID));
    assertThat(xmlThreatProtectionDependency.getVersion(), is(notNullValue()));
    assertThat(xmlThreatProtectionDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
    assertCompleteXmlPolicyTag(element);
}
Also used : XmlPolicyTagMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.threatprotection.XmlPolicyTagMigrationStep) 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)

Example 20 with PomModel

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

the class IpFilterMigrationTaskTestCase method assertPomModel.

private void assertPomModel() {
    PomModel pomModel = appModel.getPomModel().get();
    assertThat(pomModel.getDependencies().size(), is(4));
    Dependency ipFilterExtension = pomModel.getDependencies().get(3);
    assertThat(ipFilterExtension.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(ipFilterExtension.getArtifactId(), is(MULE_IP_FILTER_EXTENSION_ARTIFACT_ID));
    assertThat(ipFilterExtension.getVersion(), is(notNullValue()));
    assertThat(ipFilterExtension.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)

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