use of com.mulesoft.tools.migration.project.model.pom.PomModel in project mule-migration-assistant by mulesoft.
the class ClientIdEnforcementPomContributionMigrationStepTestCase method pomContributionTest.
@Test
public void pomContributionTest() {
PomModel pm = new PomModel();
ClientIdEnforcementPomContributionMigrationStep step = new ClientIdEnforcementPomContributionMigrationStep();
step.execute(pm, mock(MigrationReport.class));
assertThat(pm.getDependencies().size(), is(1));
Dependency clientIdEnforcementDependency = pm.getDependencies().get(0);
assertThat(clientIdEnforcementDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
assertThat(clientIdEnforcementDependency.getArtifactId(), is(MULE_CLIENT_ID_ENFORCEMENT_EXTENSION_ARTIFACT_ID));
assertThat(clientIdEnforcementDependency.getVersion(), is(notNullValue()));
assertThat(clientIdEnforcementDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
}
use of com.mulesoft.tools.migration.project.model.pom.PomModel in project mule-migration-assistant by mulesoft.
the class AbstractMigrationTask method execute.
@Override
public void execute(MigrationReport report) throws Exception {
// TODO depending on the project type this may not be true
checkState(applicationModel != null, "An application model must be provided.");
List<MigrationStep> steps = enableReporting(getSteps());
try {
if (steps != null) {
MigrationStepSelector stepSelector = new MigrationStepSelector(steps);
if (shouldExecuteAllSteps(stepSelector)) {
steps.stream().filter(s -> s instanceof ExpressionMigratorAware).forEach(s -> ((ExpressionMigratorAware) s).setExpressionMigrator(getExpressionMigrator()));
stepSelector.getNameSpaceContributionSteps().forEach(s -> s.execute(applicationModel, report));
stepSelector.getApplicationModelContributionSteps().forEach(s -> {
s.setApplicationModel(applicationModel);
fetchAndProcessNodes(report, s, new ArrayList<>());
});
stepSelector.getProjectStructureContributionSteps().forEach(s -> {
s.setApplicationModel(applicationModel);
s.execute(applicationModel.getProjectBasePath(), report);
});
stepSelector.getPomContributionSteps().forEach(s -> {
s.setApplicationModel(applicationModel);
s.execute(applicationModel.getPomModel().orElse(new PomModel()), report);
});
}
}
} catch (MigrationAbortException e) {
throw e;
} catch (Exception e) {
throw new MigrationTaskException("Task execution exception. " + e.getMessage(), e);
}
}
use of com.mulesoft.tools.migration.project.model.pom.PomModel in project mule-migration-assistant by mulesoft.
the class UpdateProjectParentTest method executeWithoutProjectParentGavAndWithoutParent.
@Test
public void executeWithoutProjectParentGavAndWithoutParent() throws IOException, XmlPullParserException, URISyntaxException {
UpdateProjectParent updateProjectParent = new UpdateProjectParent();
final ApplicationModel applicationModelMock = mock(ApplicationModel.class);
when(applicationModelMock.getProjectPomParent()).thenReturn(Optional.empty());
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");
}
}
use of com.mulesoft.tools.migration.project.model.pom.PomModel in project mule-migration-assistant by mulesoft.
the class UpdateProjectParentTest method executeWithGavAndParent.
@Test
public void executeWithGavAndParent() 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(PARENT_POM).toURI());
PomModel model = new PomModel.PomModelBuilder().withPom(pomPath).build();
parent = model.getParent().get();
assertEquals(parent.getGroupId(), "com.mule.parent");
assertEquals(parent.getArtifactId(), "parent-rest");
assertEquals(parent.getVersion(), "1.0.0");
try {
updateProjectParent.execute(model, report.getReport());
Parent afterParent = model.getParent().get();
assertEquals(afterParent.getGroupId(), "com.mule");
assertEquals(afterParent.getArtifactId(), "rest-parent");
assertEquals(afterParent.getVersion(), "2.0.0");
} catch (RuntimeException e) {
fail("no exception have to be thrown");
}
}
use of com.mulesoft.tools.migration.project.model.pom.PomModel in project mule-migration-assistant by mulesoft.
the class UpdateProjectParentTest method executeWithoutProjectParentGavAndWithParent.
@Test
public void executeWithoutProjectParentGavAndWithParent() throws URISyntaxException, IOException, XmlPullParserException {
UpdateProjectParent updateProjectParent = new UpdateProjectParent();
final ApplicationModel applicationModelMock = mock(ApplicationModel.class);
when(applicationModelMock.getProjectPomParent()).thenReturn(Optional.empty());
updateProjectParent.setApplicationModel(applicationModelMock);
Path pomPath = Paths.get(getClass().getResource(PARENT_POM).toURI());
PomModel model = new PomModel.PomModelBuilder().withPom(pomPath).build();
try {
updateProjectParent.execute(model, report.getReport());
assertTrue(model.getParent().isPresent());
assertEquals("com.mule.parent", model.getParent().get().getGroupId());
assertEquals("parent-rest", model.getParent().get().getArtifactId());
assertEquals("1.0.0", model.getParent().get().getVersion());
} catch (RuntimeException e) {
fail("no exception have to be thrown");
}
}
Aggregations