Search in sources :

Example 6 with MigrationStep

use of com.mulesoft.tools.migration.step.MigrationStep in project mule-migration-assistant by mulesoft.

the class SoapkitMigrationTask method getSteps.

@Override
public List<MigrationStep> getSteps() {
    List<MigrationStep> steps = new ArrayList<>();
    steps.add(new SoapkitMigrationTaskPomContribution());
    steps.add(new SoapkitRouterConfig());
    steps.add(new SoapkitRouter());
    steps.add(new SoapkitHttpListenerMapping());
    steps.add(new SoapkitWsdlLocation());
    steps.add(new SoapkitFault());
    return steps;
}
Also used : SoapkitRouter(com.mulesoft.tools.migration.library.soapkit.steps.SoapkitRouter) SoapkitHttpListenerMapping(com.mulesoft.tools.migration.library.soapkit.steps.SoapkitHttpListenerMapping) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) ArrayList(java.util.ArrayList) SoapkitWsdlLocation(com.mulesoft.tools.migration.library.soapkit.steps.SoapkitWsdlLocation) SoapkitFault(com.mulesoft.tools.migration.library.soapkit.steps.SoapkitFault) SoapkitRouterConfig(com.mulesoft.tools.migration.library.soapkit.steps.SoapkitRouterConfig) SoapkitMigrationTaskPomContribution(com.mulesoft.tools.migration.library.soapkit.steps.SoapkitMigrationTaskPomContribution)

Example 7 with MigrationStep

use of com.mulesoft.tools.migration.step.MigrationStep in project mule-migration-assistant by mulesoft.

the class AbstractMigrationTaskTest method executeWithFailedMigrationStep.

@Test(expected = MigrationTaskException.class)
public void executeWithFailedMigrationStep() throws Exception {
    NamespaceContribution namespaceContribution = mock(NamespaceContribution.class);
    doThrow(NullPointerException.class).when(namespaceContribution).execute(eq(applicationModelMock), any(MigrationReport.class));
    List<MigrationStep> steps = new ArrayList<>();
    steps.add(namespaceContribution);
    migrationTask.setApplicationModel(applicationModelMock);
    ((MigrationTaskImpl) migrationTask).setMigrationSteps(steps);
    migrationTask.execute(mock(MigrationReport.class));
}
Also used : NamespaceContribution(com.mulesoft.tools.migration.step.category.NamespaceContribution) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) Test(org.junit.Test)

Example 8 with MigrationStep

use of com.mulesoft.tools.migration.step.MigrationStep in project mule-migration-assistant by mulesoft.

the class AbstractMigrationTaskTest method execute.

@Test
public void execute() throws Exception {
    NamespaceContribution namespaceContributionMock = mock(NamespaceContribution.class);
    ApplicationModelContribution applicationModelContributionMock = mock(ApplicationModelContribution.class);
    ProjectStructureContribution projectStructureContributionMock = mock(ProjectStructureContribution.class);
    PomContribution pomContributionMock = mock(PomContribution.class);
    List<MigrationStep> steps = new ArrayList<>();
    steps.add(namespaceContributionMock);
    steps.add(applicationModelContributionMock);
    steps.add(projectStructureContributionMock);
    steps.add(pomContributionMock);
    InOrder inOrder = Mockito.inOrder(steps.toArray());
    migrationTask.setApplicationModel(applicationModelMock);
    ((MigrationTaskImpl) migrationTask).setMigrationSteps(new ArrayList<>(steps));
    migrationTask.execute(mock(MigrationReport.class));
    verify(namespaceContributionMock, times(1)).execute(any(ApplicationModel.class), any(MigrationReport.class));
    verify(applicationModelContributionMock, times(2)).getAppliedTo();
    verify(projectStructureContributionMock, times(1)).execute(isNull(), any(MigrationReport.class));
    verify(pomContributionMock, times(1)).execute(any(PomModel.class), any(MigrationReport.class));
    inOrder.verify(namespaceContributionMock).execute(any(ApplicationModel.class), any(MigrationReport.class));
    inOrder.verify(projectStructureContributionMock).execute(isNull(), any(MigrationReport.class));
    inOrder.verify(pomContributionMock).execute(any(PomModel.class), any(MigrationReport.class));
}
Also used : InOrder(org.mockito.InOrder) NamespaceContribution(com.mulesoft.tools.migration.step.category.NamespaceContribution) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) PomContribution(com.mulesoft.tools.migration.step.category.PomContribution) ProjectStructureContribution(com.mulesoft.tools.migration.step.category.ProjectStructureContribution) ApplicationModelContribution(com.mulesoft.tools.migration.step.category.ApplicationModelContribution) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Test(org.junit.Test)

Example 9 with MigrationStep

use of com.mulesoft.tools.migration.step.MigrationStep in project mule-migration-assistant by mulesoft.

the class ApikitMigrationTask method getSteps.

@Override
public List<MigrationStep> getSteps() {
    List<MigrationStep> steps = new ArrayList<>();
    steps.add(new ApikitMigrationTaskPomContribution());
    steps.add(new ApikitNamespace());
    steps.add(new ApikitRouterConfig());
    steps.add(new ApikitHttpListenerMapping());
    steps.add(new ApikitErrorHandler());
    steps.add(new ApikitApiLocation());
    return steps;
}
Also used : ApikitErrorHandler(com.mulesoft.tools.migration.library.apikit.steps.ApikitErrorHandler) ApikitMigrationTaskPomContribution(com.mulesoft.tools.migration.library.apikit.steps.ApikitMigrationTaskPomContribution) ApikitRouterConfig(com.mulesoft.tools.migration.library.apikit.steps.ApikitRouterConfig) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) ArrayList(java.util.ArrayList) ApikitNamespace(com.mulesoft.tools.migration.library.apikit.steps.ApikitNamespace) ApikitHttpListenerMapping(com.mulesoft.tools.migration.library.apikit.steps.ApikitHttpListenerMapping) ApikitApiLocation(com.mulesoft.tools.migration.library.apikit.steps.ApikitApiLocation)

Example 10 with MigrationStep

use of com.mulesoft.tools.migration.step.MigrationStep 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);
    }
}
Also used : System.lineSeparator(java.lang.System.lineSeparator) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) Collectors(java.util.stream.Collectors) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) Preconditions.checkState(com.google.common.base.Preconditions.checkState) XMLOutputter(org.jdom2.output.XMLOutputter) ArrayList(java.util.ArrayList) ExpressionMigrator(com.mulesoft.tools.migration.util.ExpressionMigrator) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) List(java.util.List) MigrationTaskException(com.mulesoft.tools.migration.exception.MigrationTaskException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExpressionMigratorAware(com.mulesoft.tools.migration.step.ExpressionMigratorAware) MigrationStepException(com.mulesoft.tools.migration.exception.MigrationStepException) MigrationAbortException(com.mulesoft.tools.migration.exception.MigrationAbortException) ReportingStep(com.mulesoft.tools.migration.step.ReportingStep) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) ApplicationModelContribution(com.mulesoft.tools.migration.step.category.ApplicationModelContribution) Element(org.jdom2.Element) MigrationAbortException(com.mulesoft.tools.migration.exception.MigrationAbortException) ExpressionMigratorAware(com.mulesoft.tools.migration.step.ExpressionMigratorAware) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) MigrationTaskException(com.mulesoft.tools.migration.exception.MigrationTaskException) MigrationStepException(com.mulesoft.tools.migration.exception.MigrationStepException) MigrationAbortException(com.mulesoft.tools.migration.exception.MigrationAbortException) MigrationTaskException(com.mulesoft.tools.migration.exception.MigrationTaskException)

Aggregations

MigrationStep (com.mulesoft.tools.migration.step.MigrationStep)17 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)11 Test (org.junit.Test)11 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)10 ArrayList (java.util.ArrayList)9 XMLOutputter (org.jdom2.output.XMLOutputter)9 Path (java.nio.file.Path)8 List (java.util.List)8 Document (org.jdom2.Document)8 Before (org.junit.Before)8 POLICY_APPLICATION_MODEL_PATH (com.mulesoft.tools.migration.library.gateway.TestConstants.POLICY_APPLICATION_MODEL_PATH)7 POLICY_EXAMPLES_PATH (com.mulesoft.tools.migration.library.gateway.TestConstants.POLICY_EXAMPLES_PATH)7 BasicStructureMigrationTask (com.mulesoft.tools.migration.library.gateway.tasks.BasicStructureMigrationTask)7 DocumentHelper.getDocument (com.mulesoft.tools.migration.library.gateway.tasks.DocumentHelper.getDocument)7 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.library.gateway.tasks.DocumentHelper.getElementsFromDocument)7 ProjectType (com.mulesoft.tools.migration.project.ProjectType)7 AbstractApplicationModelMigrationStep (com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep)7 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)7 Arrays.asList (java.util.Arrays.asList)7 Collection (java.util.Collection)7