Search in sources :

Example 1 with AbstractApplicationModelMigrationStep

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

the class ClientIdEnforcementPolicyMigrationTestCase method setUp.

@Before
public void setUp() throws Exception {
    ApplicationModel.ApplicationModelBuilder amb = new ApplicationModel.ApplicationModelBuilder();
    amb.withProjectType(ProjectType.MULE_THREE_POLICY);
    amb.withProjectBasePath(POLICY_APPLICATION_MODEL_PATH);
    appModel = amb.build();
    doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
    ClientIdEnforcementMigrationTask clientIdEnforcementMigrationTask = new ClientIdEnforcementMigrationTask();
    clientIdEnforcementMigrationTask.setApplicationModel(appModel);
    steps = clientIdEnforcementMigrationTask.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
    MuleElementsMigrationTask muleElementsMigrationTask = new MuleElementsMigrationTask();
    muleElementsMigrationTask.setApplicationModel(appModel);
    List<MigrationStep> policyUtilsMigrationSteps = muleElementsMigrationTask.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
    steps.addAll(policyUtilsMigrationSteps);
    BasicStructureMigrationTask basicStructureTask = new BasicStructureMigrationTask();
    List<MigrationStep> basicStructureSteps = basicStructureTask.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
    steps.addAll(basicStructureSteps);
}
Also used : RunWith(org.junit.runner.RunWith) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) POLICY_APPLICATION_MODEL_PATH(com.mulesoft.tools.migration.library.gateway.TestConstants.POLICY_APPLICATION_MODEL_PATH) Document(org.jdom2.Document) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) Arrays.asList(java.util.Arrays.asList) After(org.junit.After) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) BasicStructureMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.BasicStructureMigrationTask) Path(java.nio.file.Path) DocumentHelper.getDocument(com.mulesoft.tools.migration.library.gateway.tasks.DocumentHelper.getDocument) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) MIGRATION_RESOURCES_PATH(com.mulesoft.tools.migration.library.gateway.TestConstants.MIGRATION_RESOURCES_PATH) Format(org.jdom2.output.Format) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Collection(java.util.Collection) MuleElementsMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.MuleElementsMigrationTask) Test(org.junit.Test) ProjectType(com.mulesoft.tools.migration.project.ProjectType) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) File(java.io.File) XMLOutputter(org.jdom2.output.XMLOutputter) CompareMatcher.isSimilarTo(org.xmlunit.matchers.CompareMatcher.isSimilarTo) IOUtils(org.apache.commons.io.IOUtils) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.library.gateway.tasks.DocumentHelper.getElementsFromDocument) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) POLICY_EXAMPLES_PATH(com.mulesoft.tools.migration.library.gateway.TestConstants.POLICY_EXAMPLES_PATH) ClientIdEnforcementMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.ClientIdEnforcementMigrationTask) Mockito.mock(org.mockito.Mockito.mock) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) ClientIdEnforcementMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.ClientIdEnforcementMigrationTask) BasicStructureMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.BasicStructureMigrationTask) MuleElementsMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.MuleElementsMigrationTask) Before(org.junit.Before)

Example 2 with AbstractApplicationModelMigrationStep

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

the class ThrottlingPolicyMigrationTestCase method execute.

@Test
public void execute() throws Exception {
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    steps.forEach(step -> migrate((AbstractApplicationModelMigrationStep) step));
    String xmlString = outputter.outputString(doc);
    assertThat(xmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetPath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) Test(org.junit.Test)

Example 3 with AbstractApplicationModelMigrationStep

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

the class FederationPolicyMigrationTestCase method setUp.

@Before
public void setUp() throws Exception {
    ApplicationModel.ApplicationModelBuilder amb = new ApplicationModel.ApplicationModelBuilder();
    amb.withProjectType(ProjectType.MULE_THREE_POLICY);
    amb.withProjectBasePath(POLICY_APPLICATION_MODEL_PATH);
    appModel = amb.build();
    doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
    FederationMigrationTask task = new FederationMigrationTask();
    task.setApplicationModel(appModel);
    steps = task.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
    BasicStructureMigrationTask basicStructureTask = new BasicStructureMigrationTask();
    basicStructureTask.setApplicationModel(appModel);
    List<MigrationStep> basicStructureSteps = basicStructureTask.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
    steps.addAll(basicStructureSteps);
}
Also used : FederationMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.FederationMigrationTask) RunWith(org.junit.runner.RunWith) FederationMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.FederationMigrationTask) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) POLICY_APPLICATION_MODEL_PATH(com.mulesoft.tools.migration.library.gateway.TestConstants.POLICY_APPLICATION_MODEL_PATH) Document(org.jdom2.Document) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) Arrays.asList(java.util.Arrays.asList) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) BasicStructureMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.BasicStructureMigrationTask) Path(java.nio.file.Path) DocumentHelper.getDocument(com.mulesoft.tools.migration.library.gateway.tasks.DocumentHelper.getDocument) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) Format(org.jdom2.output.Format) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Collection(java.util.Collection) Test(org.junit.Test) ProjectType(com.mulesoft.tools.migration.project.ProjectType) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) XMLOutputter(org.jdom2.output.XMLOutputter) CompareMatcher.isSimilarTo(org.xmlunit.matchers.CompareMatcher.isSimilarTo) IOUtils(org.apache.commons.io.IOUtils) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.library.gateway.tasks.DocumentHelper.getElementsFromDocument) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) POLICY_EXAMPLES_PATH(com.mulesoft.tools.migration.library.gateway.TestConstants.POLICY_EXAMPLES_PATH) Mockito.mock(org.mockito.Mockito.mock) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) BasicStructureMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.BasicStructureMigrationTask) Before(org.junit.Before)

Example 4 with AbstractApplicationModelMigrationStep

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

the class IpFilterPolicyMigrationTestCase method execute.

@Test
public void execute() throws Exception {
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    steps.forEach(step -> migrate((AbstractApplicationModelMigrationStep) step));
    String xmlString = outputter.outputString(doc);
    assertThat(xmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetPath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) Test(org.junit.Test)

Example 5 with AbstractApplicationModelMigrationStep

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

the class IpFilterPolicyMigrationTestCase method setUp.

@Before
public void setUp() throws Exception {
    ApplicationModel.ApplicationModelBuilder amb = new ApplicationModel.ApplicationModelBuilder();
    amb.withProjectType(ProjectType.MULE_THREE_POLICY);
    amb.withProjectBasePath(POLICY_APPLICATION_MODEL_PATH);
    appModel = amb.build();
    doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
    IpFilterMigrationTask ipFilterMigrationTask = new IpFilterMigrationTask();
    ipFilterMigrationTask.setApplicationModel(appModel);
    steps = ipFilterMigrationTask.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
    MuleElementsMigrationTask muleElementsMigrationTask = new MuleElementsMigrationTask();
    muleElementsMigrationTask.setApplicationModel(appModel);
    List<MigrationStep> policyUtilsMigrationSteps = muleElementsMigrationTask.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
    steps.addAll(policyUtilsMigrationSteps);
    BasicStructureMigrationTask basicStructureTask = new BasicStructureMigrationTask();
    List<MigrationStep> basicStructureSteps = basicStructureTask.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
    steps.addAll(basicStructureSteps);
}
Also used : RunWith(org.junit.runner.RunWith) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) POLICY_APPLICATION_MODEL_PATH(com.mulesoft.tools.migration.library.gateway.TestConstants.POLICY_APPLICATION_MODEL_PATH) Document(org.jdom2.Document) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) Arrays.asList(java.util.Arrays.asList) After(org.junit.After) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) BasicStructureMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.BasicStructureMigrationTask) Path(java.nio.file.Path) DocumentHelper.getDocument(com.mulesoft.tools.migration.library.gateway.tasks.DocumentHelper.getDocument) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) MIGRATION_RESOURCES_PATH(com.mulesoft.tools.migration.library.gateway.TestConstants.MIGRATION_RESOURCES_PATH) Format(org.jdom2.output.Format) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Collection(java.util.Collection) MuleElementsMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.MuleElementsMigrationTask) Test(org.junit.Test) ProjectType(com.mulesoft.tools.migration.project.ProjectType) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) File(java.io.File) XMLOutputter(org.jdom2.output.XMLOutputter) CompareMatcher.isSimilarTo(org.xmlunit.matchers.CompareMatcher.isSimilarTo) IOUtils(org.apache.commons.io.IOUtils) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) IpFilterMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.IpFilterMigrationTask) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.library.gateway.tasks.DocumentHelper.getElementsFromDocument) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) POLICY_EXAMPLES_PATH(com.mulesoft.tools.migration.library.gateway.TestConstants.POLICY_EXAMPLES_PATH) Mockito.mock(org.mockito.Mockito.mock) IpFilterMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.IpFilterMigrationTask) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) AbstractApplicationModelMigrationStep(com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep) BasicStructureMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.BasicStructureMigrationTask) MuleElementsMigrationTask(com.mulesoft.tools.migration.library.gateway.tasks.MuleElementsMigrationTask) Before(org.junit.Before)

Aggregations

AbstractApplicationModelMigrationStep (com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep)18 XMLOutputter (org.jdom2.output.XMLOutputter)15 Test (org.junit.Test)15 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)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 MigrationStep (com.mulesoft.tools.migration.step.MigrationStep)7 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)7 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)7 Path (java.nio.file.Path)7 Arrays.asList (java.util.Arrays.asList)7 Collection (java.util.Collection)7 List (java.util.List)7 Collectors.toList (java.util.stream.Collectors.toList)7 IOUtils (org.apache.commons.io.IOUtils)7