Search in sources :

Example 1 with HTTPCleanupTask

use of com.mulesoft.tools.migration.library.mule.tasks.HTTPCleanupTask 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 2 with HTTPCleanupTask

use of com.mulesoft.tools.migration.library.mule.tasks.HTTPCleanupTask 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)

Aggregations

HTTPCleanupTask (com.mulesoft.tools.migration.library.mule.tasks.HTTPCleanupTask)2 MigrationCleanTask (com.mulesoft.tools.migration.library.mule.tasks.MigrationCleanTask)2 PostprocessGeneral (com.mulesoft.tools.migration.library.mule.tasks.PostprocessGeneral)2 PostprocessMuleApplication (com.mulesoft.tools.migration.library.mule.tasks.PostprocessMuleApplication)2 SpringMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.SpringMigrationTask)2 AbstractMigrationTask (com.mulesoft.tools.migration.task.AbstractMigrationTask)2 ArrayList (java.util.ArrayList)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 DocumentHelper.getDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getDocument)1 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument)1 DbMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.DbMigrationTask)1 DomainAppMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.DomainAppMigrationTask)1 EndpointsMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.EndpointsMigrationTask)1 FiltersMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.FiltersMigrationTask)1 HTTPMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.HTTPMigrationTask)1 JmsDomainMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.JmsDomainMigrationTask)1 JmsMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.JmsMigrationTask)1 MuleCoreComponentsMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.MuleCoreComponentsMigrationTask)1 SecurityFiltersMigrationTask (com.mulesoft.tools.migration.library.mule.tasks.SecurityFiltersMigrationTask)1 MelToDwExpressionMigrator (com.mulesoft.tools.migration.library.tools.MelToDwExpressionMigrator)1