Search in sources :

Example 6 with AbstractMigrationTask

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;
}
Also used : PostprocessGeneral(com.mulesoft.tools.migration.library.mule.tasks.PostprocessGeneral) PostprocessMuleApplication(com.mulesoft.tools.migration.library.mule.tasks.PostprocessMuleApplication) FiltersMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.FiltersMigrationTask) SecurityFiltersMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.SecurityFiltersMigrationTask) AbstractMigrationTask(com.mulesoft.tools.migration.task.AbstractMigrationTask) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) SpringMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.SpringMigrationTask) MigrationCleanTask(com.mulesoft.tools.migration.library.mule.tasks.MigrationCleanTask) HTTPCleanupTask(com.mulesoft.tools.migration.library.mule.tasks.HTTPCleanupTask)

Example 7 with AbstractMigrationTask

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;
}
Also used : FederationMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.FederationMigrationTask) PolicyUtilsMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.PolicyUtilsMigrationTask) AbstractMigrationTask(com.mulesoft.tools.migration.task.AbstractMigrationTask) IpFilterMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.IpFilterMigrationTask) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) ClientIdEnforcementMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.ClientIdEnforcementMigrationTask) RamlProxyMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.RamlProxyMigrationTask) BasicStructureMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.BasicStructureMigrationTask) RamlProxyMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.RamlProxyMigrationTask) ProxyMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.ProxyMigrationTask) ThreatProtectionMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.ThreatProtectionMigrationTask) ThrottlingMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.ThrottlingMigrationTask) HttpMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.HttpMigrationTask) MuleElementsMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.MuleElementsMigrationTask)

Example 8 with AbstractMigrationTask

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;
}
Also used : MigrationTask(com.mulesoft.tools.migration.task.MigrationTask) AbstractMigrationTask(com.mulesoft.tools.migration.task.AbstractMigrationTask) ArrayList(java.util.ArrayList) Namespace(org.jdom2.Namespace) Namespace.getNamespace(org.jdom2.Namespace.getNamespace) MigrationStepSelector(com.mulesoft.tools.migration.task.MigrationStepSelector)

Example 9 with AbstractMigrationTask

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);
            }
        }
    }
}
Also used : DbMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.DbMigrationTask) EndpointsMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.EndpointsMigrationTask) HashMap(java.util.HashMap) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) SpringMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.SpringMigrationTask) MigrationCleanTask(com.mulesoft.tools.migration.library.mule.tasks.MigrationCleanTask) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Document(org.jdom2.Document) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument) DocumentHelper.getDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getDocument) ExpressionMigratorAware(com.mulesoft.tools.migration.step.ExpressionMigratorAware) ApplicationModelContribution(com.mulesoft.tools.migration.step.category.ApplicationModelContribution) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) JmsMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.JmsMigrationTask) JmsDomainMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.JmsDomainMigrationTask) Path(java.nio.file.Path) PostprocessGeneral(com.mulesoft.tools.migration.library.mule.tasks.PostprocessGeneral) PostprocessMuleApplication(com.mulesoft.tools.migration.library.mule.tasks.PostprocessMuleApplication) DomainAppMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.DomainAppMigrationTask) AbstractMigrationTask(com.mulesoft.tools.migration.task.AbstractMigrationTask) HTTPCleanupTask(com.mulesoft.tools.migration.library.mule.tasks.HTTPCleanupTask) Namespace(org.jdom2.Namespace) MelToDwExpressionMigrator(com.mulesoft.tools.migration.library.tools.MelToDwExpressionMigrator) HTTPMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.HTTPMigrationTask) MuleCoreComponentsMigrationTask(com.mulesoft.tools.migration.library.mule.tasks.MuleCoreComponentsMigrationTask) Before(org.junit.Before)

Example 10 with AbstractMigrationTask

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));
}
Also used : DefaultMigrationReport(com.mulesoft.tools.migration.report.DefaultMigrationReport) AbstractMigrationTask(com.mulesoft.tools.migration.task.AbstractMigrationTask) DefaultMigrationReport(com.mulesoft.tools.migration.report.DefaultMigrationReport) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) Test(org.junit.Test)

Aggregations

AbstractMigrationTask (com.mulesoft.tools.migration.task.AbstractMigrationTask)11 ArrayList (java.util.ArrayList)6 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)4 MunitMigrationTask (com.mulesoft.tools.migration.library.munit.tasks.MunitMigrationTask)4 DbMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.DbMigrationTask)3 DomainAppMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.DomainAppMigrationTask)3 EndpointsMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.EndpointsMigrationTask)3 HTTPCleanupTask (com.mulesoft.tools.migration.library.mule.tasks.HTTPCleanupTask)3 HTTPMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.HTTPMigrationTask)3 JmsDomainMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.JmsDomainMigrationTask)3 JmsMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.JmsMigrationTask)3 MigrationCleanTask (com.mulesoft.tools.migration.library.mule.tasks.MigrationCleanTask)3 MuleCoreComponentsMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.MuleCoreComponentsMigrationTask)3 PostprocessGeneral (com.mulesoft.tools.migration.library.mule.tasks.PostprocessGeneral)3 PostprocessMuleApplication (com.mulesoft.tools.migration.library.mule.tasks.PostprocessMuleApplication)3 SecurityFiltersMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.SecurityFiltersMigrationTask)3 SpringMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.SpringMigrationTask)3 ApikitMigrationTask (com.mulesoft.tools.migration.library.apikit.tasks.ApikitMigrationTask)2 CompressionMigrationTask (com.mulesoft.tools.migration.library.mule.steps.compression.CompressionMigrationTask)2 AmqpMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.AmqpMigrationTask)2