Search in sources :

Example 6 with PomModel

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

the class UpdateProjectParentTest method executeWithProjectParentGavAndWithoutParent.

@Test
public void executeWithProjectParentGavAndWithoutParent() throws URISyntaxException, IOException, XmlPullParserException {
    UpdateProjectParent updateProjectParent = new UpdateProjectParent();
    final ApplicationModel applicationModelMock = mock(ApplicationModel.class);
    Parent parent = new Parent.ParentBuilder().withGroupId("com.mule").withArtifactId("rest-parent").withVersion("2.0.0").build();
    when(applicationModelMock.getProjectPomParent()).thenReturn(Optional.of(parent));
    updateProjectParent.setApplicationModel(applicationModelMock);
    Path pomPath = Paths.get(getClass().getResource(POM).toURI());
    PomModel model = new PomModel.PomModelBuilder().withPom(pomPath).build();
    try {
        updateProjectParent.execute(model, report.getReport());
        assertTrue(!model.getParent().isPresent());
    } catch (RuntimeException e) {
        fail("no exception have to be thrown");
    }
}
Also used : Path(java.nio.file.Path) Parent(com.mulesoft.tools.migration.project.model.pom.Parent) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Test(org.junit.Test)

Example 7 with PomModel

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

the class FixedTimeAlgorithmMigrationStepTestCase method rateLimitPomContributionTest.

@Test
public void rateLimitPomContributionTest() throws Exception {
    FixedTimeFrameAlgorithmMigrationStep step = new FixedTimeFrameAlgorithmMigrationStep();
    step.setApplicationModel(appModel);
    Element element = createPolicy(1, FIXED_TIME_FRAME_ALGORITHM_TAG_NAME, 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) FixedTimeFrameAlgorithmMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.throttling.FixedTimeFrameAlgorithmMigrationStep) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Test(org.junit.Test)

Example 8 with PomModel

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

the class RamlValidatorPomContributionMigrationStepTestCase method pomContributionTestWithPreviousDependency.

@Test
public void pomContributionTestWithPreviousDependency() {
    PomModel pm = new PomModel();
    pm.addDependency(getRamlDependency());
    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 9 with PomModel

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

the class HttpMigrationTaskTestCase method assertPomModel.

private void assertPomModel() {
    PomModel pomModel = appModel.getPomModel().get();
    assertThat(pomModel.getDependencies().size(), is(1));
    Dependency httpPolicyTransform = pomModel.getDependencies().get(0);
    assertThat(httpPolicyTransform.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(httpPolicyTransform.getArtifactId(), is(MULE_HTTP_POLICY_TRANSFORM_EXTENSION_ARTIFACT_ID));
    assertThat(httpPolicyTransform.getVersion(), is(notNullValue()));
    assertThat(httpPolicyTransform.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 10 with PomModel

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

the class MuleElementsMigrationTaskTestCase method assertPomModel.

private void assertPomModel() {
    PomModel pomModel = appModel.getPomModel().get();
    assertThat(pomModel.getDependencies().size(), is(1));
    Dependency httpPolicyTransformExtension = pomModel.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));
}
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