Search in sources :

Example 21 with PomModel

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

the class RamlProxyMigrationTaskTestCase method execute.

@Test
public void execute() throws Exception {
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    steps.forEach(step -> migrate(step));
    String xmlString = outputter.outputString(doc);
    assertThat(xmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetPath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
    PomModel pm = appModel.getPomModel().get();
    assertThat(pm.getDependencies().size(), is(1));
    assertRestValidatorDependency(pm);
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Test(org.junit.Test)

Example 22 with PomModel

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

the class SlaBasedAlgorithmMigrationStepTestCase method rateLimitSlaPomContributionTest.

@Test
public void rateLimitSlaPomContributionTest() throws Exception {
    SlaBasedAlgorithmMigrationStep step = new SlaBasedAlgorithmMigrationStep();
    step.setApplicationModel(appModel);
    Element element = getSlaPolicy(1, false);
    step.execute(element, reportMock);
    PomModel pm = appModel.getPomModel().get();
    assertThat(pm.getDependencies().size(), is(2));
    Dependency policyTransformExtensionDependency = pm.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 : Element(org.jdom2.Element) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) SlaBasedAlgorithmMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.throttling.SlaBasedAlgorithmMigrationStep) Test(org.junit.Test)

Example 23 with PomModel

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

the class RamlValidatorPomContributionMigrationStepTestCase method pomContributionTestWithNoPreviousDependency.

@Test
public void pomContributionTestWithNoPreviousDependency() {
    PomModel pm = new PomModel();
    RamlValidatorPomContributionMigrationStep step = new RamlValidatorPomContributionMigrationStep();
    step.execute(pm, mock(MigrationReport.class));
    assertThat(pm.getDependencies().size(), is(1));
    Dependency httpPolicyTransformExtension = pm.getDependencies().get(0);
    assertThat(httpPolicyTransformExtension.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(httpPolicyTransformExtension.getArtifactId(), is(MULE_REST_VALIDATOR_EXTENSION));
    assertThat(httpPolicyTransformExtension.getVersion(), is(notNullValue()));
    assertThat(httpPolicyTransformExtension.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
}
Also used : PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Test(org.junit.Test)

Example 24 with PomModel

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

the class JsonPolicyTagMigrationStepTestCase method jsonPomContributionTest.

@Test
public void jsonPomContributionTest() {
    JsonPolicyTagMigrationStep step = new JsonPolicyTagMigrationStep();
    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 jsonThreatProtectionDependency = pm.getDependencies().get(0);
    assertThat(jsonThreatProtectionDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(jsonThreatProtectionDependency.getArtifactId(), is(MULE_JSON_THREAT_PROTECTION_EXTENSION_ARTIFACT_ID));
    assertThat(jsonThreatProtectionDependency.getVersion(), is(notNullValue()));
    assertThat(jsonThreatProtectionDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
    assertJsonPolicyTag(element);
}
Also used : JsonPolicyTagMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.threatprotection.JsonPolicyTagMigrationStep) 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 25 with PomModel

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

the class MelToDwExpressionMigratorTest method migrateInstanceOfExpression.

@Test
public void migrateInstanceOfExpression() {
    PomModel pomModel = PomModelUtils.buildMinimalMule4ApplicationPom("org.fake", "fake-app", "1.0.0", "mule-application");
    when(modelMock.getPomModel()).thenReturn(Optional.of(pomModel));
    Element elementMock = mock(Element.class);
    String originalExpression = "a instanceof org.pepe.Pepito";
    assertThat("Pom model should not have the java module dependency", pomModel.getDependencies().stream().noneMatch(d -> d.getArtifactId().equals("mule-java-module")));
    String migratedExpression = expressionMigrator.migrateExpression("#[" + originalExpression + "]", false, elementMock);
    assertThat("Migrated expression is not the expected", migratedExpression, equalTo("#[%dw 2.0 --- Java::isInstanceOf(vars.a, 'org.pepe.Pepito')]"));
    assertThat("Pom model should have the java module dependency", pomModel.getDependencies().stream().anyMatch(d -> d.getArtifactId().equals("mule-java-module")));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) PomModelUtils(com.mulesoft.tools.migration.project.model.pom.PomModelUtils) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) StringUtils(org.apache.commons.lang3.StringUtils) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) Mockito.verify(org.mockito.Mockito.verify) ExpressionMigrator(com.mulesoft.tools.migration.util.ExpressionMigrator) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) Matchers.eq(org.mockito.Matchers.eq) Optional(java.util.Optional) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Mockito.mock(org.mockito.Mockito.mock) Element(org.jdom2.Element) Before(org.junit.Before) Element(org.jdom2.Element) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) 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