Search in sources :

Example 1 with AbstractApikitMigrationStep

use of com.mulesoft.tools.migration.library.apikit.steps.AbstractApikitMigrationStep in project mule-migration-assistant by mulesoft.

the class ApikitMigrationTest method execute.

@Test
public void execute() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
    steps.forEach(step -> getElementsFromDocument(doc, ((AbstractApikitMigrationStep) step).getAppliedTo().getExpression()).forEach(node -> step.execute(node, mock(MigrationReport.class))));
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    String xmlString = outputter.outputString(doc);
    assertThat(xmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetPath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
}
Also used : Mockito.doCallRealMethod(org.mockito.Mockito.doCallRealMethod) RunWith(org.junit.runner.RunWith) AbstractApikitMigrationStep(com.mulesoft.tools.migration.library.apikit.steps.AbstractApikitMigrationStep) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) Matchers.anyString(org.mockito.Matchers.anyString) Document(org.jdom2.Document) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) Namespace(org.jdom2.Namespace) URI(java.net.URI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Path(java.nio.file.Path) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) Format(org.jdom2.output.Format) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Test(org.junit.Test) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) File(java.io.File) XMLOutputter(org.jdom2.output.XMLOutputter) Matchers.any(org.mockito.Matchers.any) IOUtils(org.apache.commons.io.IOUtils) DocumentHelper.getDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getDocument) CompareMatcher.isSimilarTo(org.xmlunit.matchers.CompareMatcher.isSimilarTo) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ApikitMigrationTask(com.mulesoft.tools.migration.library.apikit.tasks.ApikitMigrationTask) Paths(java.nio.file.Paths) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument) Mockito.mock(org.mockito.Mockito.mock) XMLOutputter(org.jdom2.output.XMLOutputter) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) AbstractApikitMigrationStep(com.mulesoft.tools.migration.library.apikit.steps.AbstractApikitMigrationStep) Matchers.anyString(org.mockito.Matchers.anyString) Document(org.jdom2.Document) DocumentHelper.getDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getDocument) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument) Test(org.junit.Test)

Example 2 with AbstractApikitMigrationStep

use of com.mulesoft.tools.migration.library.apikit.steps.AbstractApikitMigrationStep in project mule-migration-assistant by mulesoft.

the class ApikitMigrationTest method setUp.

@Before
public void setUp() {
    final ApplicationModel applicationModel = getApplicationModel();
    final ApikitMigrationTask apikitMigrationTask = new ApikitMigrationTask();
    steps = apikitMigrationTask.getSteps().stream().filter(step -> step instanceof AbstractApikitMigrationStep).collect(toList());
    steps.forEach(step -> ((AbstractApikitMigrationStep) step).setApplicationModel(applicationModel));
}
Also used : ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) AbstractApikitMigrationStep(com.mulesoft.tools.migration.library.apikit.steps.AbstractApikitMigrationStep) ApikitMigrationTask(com.mulesoft.tools.migration.library.apikit.tasks.ApikitMigrationTask) Before(org.junit.Before)

Aggregations

AbstractApikitMigrationStep (com.mulesoft.tools.migration.library.apikit.steps.AbstractApikitMigrationStep)2 ApikitMigrationTask (com.mulesoft.tools.migration.library.apikit.tasks.ApikitMigrationTask)2 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)2 Before (org.junit.Before)2 DocumentHelper.getDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getDocument)1 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument)1 MigrationStep (com.mulesoft.tools.migration.step.MigrationStep)1 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)1 File (java.io.File)1 URI (java.net.URI)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 IOUtils (org.apache.commons.io.IOUtils)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Document (org.jdom2.Document)1 Namespace (org.jdom2.Namespace)1