use of com.mulesoft.tools.migration.task.AbstractMigrationTask in project mule-migration-assistant by mulesoft.
the class MigrationTaskLocator method getCoreAfterMigrationTasks.
public List<AbstractMigrationTask> getCoreAfterMigrationTasks() {
List<AbstractMigrationTask> coreMigrationTasks = new ArrayList<>();
coreMigrationTasks.add(new FiltersMigrationTask());
// Spring has to run after MUnit, since MUnit in Mule 3 has some custom spring components that are removed by the migrator
coreMigrationTasks.add(new SpringMigrationTask());
coreMigrationTasks.add(new HTTPCleanupTask());
coreMigrationTasks.add(new MigrationCleanTask());
coreMigrationTasks.add(new PostprocessGeneral());
coreMigrationTasks.add(new PostprocessMuleApplication());
return coreMigrationTasks;
}
use of com.mulesoft.tools.migration.task.AbstractMigrationTask in project mule-migration-assistant by mulesoft.
the class MigrationTaskLocator method getGatewayMigrationTasks.
protected List<AbstractMigrationTask> getGatewayMigrationTasks() {
List<AbstractMigrationTask> gatewayMigrationTasks = new ArrayList<>();
gatewayMigrationTasks.add(new ProxyMigrationTask());
gatewayMigrationTasks.add(new RamlProxyMigrationTask());
gatewayMigrationTasks.add(new IpFilterMigrationTask());
gatewayMigrationTasks.add(new ThreatProtectionMigrationTask());
gatewayMigrationTasks.add(new ThrottlingMigrationTask());
gatewayMigrationTasks.add(new ClientIdEnforcementMigrationTask());
gatewayMigrationTasks.add(new FederationMigrationTask());
gatewayMigrationTasks.add(new HttpMigrationTask());
gatewayMigrationTasks.add(new MuleElementsMigrationTask());
gatewayMigrationTasks.add(new PolicyUtilsMigrationTask());
gatewayMigrationTasks.add(new BasicStructureMigrationTask());
return gatewayMigrationTasks;
}
use of com.mulesoft.tools.migration.task.AbstractMigrationTask in project mule-migration-assistant by mulesoft.
the class AdditionalNamespacesFactory method getTasksDeclaredNamespaces.
public static List<Namespace> getTasksDeclaredNamespaces(List<AbstractMigrationTask> migrationTasks) {
List<Namespace> taskSupportedNamespaces = new ArrayList<>();
for (MigrationTask task : ofNullable(migrationTasks).orElse(emptyList())) {
MigrationStepSelector stepSelector = new MigrationStepSelector(task.getSteps());
stepSelector.getApplicationModelContributionSteps().forEach(s -> taskSupportedNamespaces.addAll(s.getNamespacesContributions()));
}
taskSupportedNamespaces.add(getNamespace("mule", CORE_NAMESPACE.getURI()));
return taskSupportedNamespaces;
}
use of com.mulesoft.tools.migration.task.AbstractMigrationTask in project mule-migration-assistant by mulesoft.
the class DomainTest method setUp.
@Before
public void setUp() throws Exception {
originalDomainDoc = getDocument(this.getClass().getClassLoader().getResource(domainConfigPath.toString()).toURI().getPath());
domainDoc = getDocument(this.getClass().getClassLoader().getResource(domainConfigPath.toString()).toURI().getPath());
appDoc = getDocument(this.getClass().getClassLoader().getResource(appConfigPath.toString()).toURI().getPath());
MelToDwExpressionMigrator expressionMigrator = new MelToDwExpressionMigrator(report.getReport(), mock(ApplicationModel.class));
domainModel = mock(ApplicationModel.class);
when(domainModel.getNodes(any(String.class))).thenAnswer(invocation -> getElementsFromDocument(domainDoc, (String) invocation.getArguments()[0], "domain"));
when(domainModel.getNode(any(String.class))).thenAnswer(invocation -> getElementsFromDocument(domainDoc, (String) invocation.getArguments()[0], "domain").iterator().next());
when(domainModel.getNodeOptional(any(String.class))).thenAnswer(invocation -> {
List<Element> elementsFromDocument = getElementsFromDocument(domainDoc, (String) invocation.getArguments()[0], "domain");
if (elementsFromDocument.isEmpty()) {
return empty();
} else {
return of(elementsFromDocument.iterator().next());
}
});
when(domainModel.getProjectBasePath()).thenReturn(temp.newFolder().toPath());
when(domainModel.getPomModel()).thenReturn(of(mock(PomModel.class)));
final Map<Path, Document> domainModelDocs = new HashMap<>();
domainModelDocs.put(domainConfigPath, domainDoc);
when(domainModel.getApplicationDocuments()).thenReturn(domainModelDocs);
doAnswer(invocation -> {
String prefix = invocation.getArgument(0);
String uri = invocation.getArgument(1);
String schemaLocation = invocation.getArgument(2);
Namespace namespace = Namespace.getNamespace(prefix, uri);
addNameSpace(namespace, schemaLocation, domainDoc);
return null;
}).when(domainModel).addNameSpace(anyString(), anyString(), anyString());
appModel = mock(ApplicationModel.class);
when(appModel.getNodes(any(String.class))).thenAnswer(invocation -> getElementsFromDocuments((String) invocation.getArguments()[0]));
when(appModel.getNode(any(String.class))).thenAnswer(invocation -> getElementsFromDocuments((String) invocation.getArguments()[0]).iterator().next());
when(appModel.getNodeOptional(any(String.class))).thenAnswer(invocation -> {
List<Element> elementsFromDocument = getElementsFromDocuments((String) invocation.getArguments()[0]);
if (elementsFromDocument.isEmpty()) {
return empty();
} else {
return of(elementsFromDocument.iterator().next());
}
});
when(appModel.getProjectBasePath()).thenReturn(temp.newFolder().toPath());
when(appModel.getPomModel()).thenReturn(of(mock(PomModel.class)));
final Map<Path, Document> appDomainModelDocs = new HashMap<>();
appDomainModelDocs.put(domainConfigPath, originalDomainDoc);
when(appModel.getDomainDocuments()).thenReturn(appDomainModelDocs);
doAnswer(invocation -> {
String prefix = invocation.getArgument(0);
String uri = invocation.getArgument(1);
String schemaLocation = invocation.getArgument(2);
Namespace namespace = Namespace.getNamespace(prefix, uri);
addNameSpace(namespace, schemaLocation, originalDomainDoc);
addNameSpace(namespace, schemaLocation, appDoc);
return null;
}).when(appModel).addNameSpace(anyString(), anyString(), anyString());
List<AbstractMigrationTask> coreMigrationTasks = new ArrayList<>();
coreMigrationTasks.add(new MuleCoreComponentsMigrationTask());
coreMigrationTasks.add(new HTTPMigrationTask());
coreMigrationTasks.add(new DbMigrationTask());
coreMigrationTasks.add(new EndpointsMigrationTask());
coreMigrationTasks.add(new JmsDomainMigrationTask());
coreMigrationTasks.add(new JmsMigrationTask());
coreMigrationTasks.add(new DomainAppMigrationTask());
coreMigrationTasks.add(new SpringMigrationTask());
coreMigrationTasks.add(new HTTPCleanupTask());
coreMigrationTasks.add(new MigrationCleanTask());
coreMigrationTasks.add(new PostprocessGeneral());
coreMigrationTasks.add(new PostprocessMuleApplication());
appSteps = new ArrayList<>();
domainSteps = new ArrayList<>();
for (AbstractMigrationTask task : coreMigrationTasks) {
if (task.getApplicableProjectTypes().contains(MULE_FOUR_DOMAIN)) {
for (MigrationStep step : task.getSteps()) {
if (step instanceof ExpressionMigratorAware) {
((ExpressionMigratorAware) step).setExpressionMigrator(expressionMigrator);
}
if (step instanceof ApplicationModelContribution) {
((ApplicationModelContribution) step).setApplicationModel(domainModel);
}
domainSteps.add(step);
}
}
if (task.getApplicableProjectTypes().contains(MULE_FOUR_APPLICATION)) {
for (MigrationStep step : task.getSteps()) {
if (step instanceof ExpressionMigratorAware) {
((ExpressionMigratorAware) step).setExpressionMigrator(expressionMigrator);
}
if (step instanceof ApplicationModelContribution) {
((ApplicationModelContribution) step).setApplicationModel(appModel);
}
appSteps.add(step);
}
}
}
}
use of com.mulesoft.tools.migration.task.AbstractMigrationTask in project mule-migration-assistant by mulesoft.
the class MigrationJobTest method executeWithTaskThatFailsNotStopExecution.
@Test
public void executeWithTaskThatFailsNotStopExecution() throws Exception {
migrationJob = new MigrationJob.MigrationJobBuilder().withProject(originalProjectPath).withOutputProject(migratedProjectPath).withInputVersion(MULE_380_VERSION).withOuputVersion(MULE_413_VERSION).build();
AbstractMigrationTask migrationTask = mock(AbstractMigrationTask.class);
doThrow(MigrationTaskException.class).when(migrationTask).execute(any(MigrationReport.class));
when(migrationTask.getApplicableProjectTypes()).thenReturn(singleton(MULE_FOUR_APPLICATION));
migrationTasks.add(migrationTask);
Whitebox.setInternalState(migrationJob, "migrationTasks", migrationTasks);
migrationJob.execute(new DefaultMigrationReport());
verify(migrationTask, times(1)).execute(any(MigrationReport.class));
}
Aggregations