Search in sources :

Example 31 with Document

use of com.google.firestore.v1beta1.Document in project mule-migration-assistant by mulesoft.

the class SplitterTest method execute.

@Test
public void execute() throws Exception {
    Document document = Iterables.get(applicationModel.getApplicationDocuments().values(), 0);
    vmNamespaceContribution.execute(applicationModel, report.getReport());
    aggregatorsNamespaceContribution.execute(applicationModel, report.getReport());
    getElementsFromDocument(document, collectionSplitter.getAppliedTo().getExpression()).forEach(node -> collectionSplitter.execute(node, report.getReport()));
    getElementsFromDocument(document, expressionSplitter.getAppliedTo().getExpression()).forEach(node -> expressionSplitter.execute(node, report.getReport()));
    getElementsFromDocument(document, customSplitter.getAppliedTo().getExpression()).forEach(node -> customSplitter.execute(node, report.getReport()));
    getElementsFromDocument(document, mapSplitter.getAppliedTo().getExpression()).forEach(node -> mapSplitter.execute(node, report.getReport()));
    getElementsFromDocument(document, messageChunkSplitter.getAppliedTo().getExpression()).forEach(node -> messageChunkSplitter.execute(node, report.getReport()));
    getElementsFromDocument(document, aggregatorWithNoSplitter.getAppliedTo().getExpression()).forEach(node -> aggregatorWithNoSplitter.execute(node, report.getReport()));
    getElementsFromDocument(document, removeSyntheticMigrationAttributes.getAppliedTo().getExpression()).forEach(node -> removeSyntheticMigrationAttributes.execute(node, report.getReport()));
    getElementsFromDocument(document, removeSyntheticMigrationGlobalElements.getAppliedTo().getExpression()).forEach(node -> removeSyntheticMigrationGlobalElements.execute(node, report.getReport()));
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    String xmlString = outputter.outputString(document);
    assertThat(xmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetPath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Document(org.jdom2.Document) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument) Test(org.junit.Test)

Example 32 with Document

use of com.google.firestore.v1beta1.Document in project mule-migration-assistant by mulesoft.

the class SpringTest method execute.

@Test
public void execute() throws Exception {
    Path resolvedConfigPath = Paths.get(this.getClass().getClassLoader().getResource(configPath.toString()).toURI());
    ApplicationModel appModel = new ApplicationModelBuilder().withProjectBasePath(Paths.get(this.getClass().getClassLoader().getResource(SPRING_EXAMPLES_PATH.toString()).toURI())).withConfigurationFiles(asList(resolvedConfigPath)).withMuleVersion(muleVersion).withProjectType(MULE_FOUR_APPLICATION).build();
    Document doc = appModel.getApplicationDocuments().get(configPath.getFileName());
    springPropertiesPlaceholder.setApplicationModel(appModel);
    springConfigContainingMuleConfig.setApplicationModel(appModel);
    springConfigInMuleConfig.setApplicationModel(appModel);
    springBeans.setApplicationModel(appModel);
    springContext.setApplicationModel(appModel);
    springContributions.setApplicationModel(appModel);
    getElementsFromDocument(doc, springPropertiesPlaceholder.getAppliedTo().getExpression()).forEach(node -> springPropertiesPlaceholder.execute(node, report.getReport()));
    getElementsFromDocument(doc, springConfigContainingMuleConfig.getAppliedTo().getExpression(), "spring").forEach(node -> springConfigContainingMuleConfig.execute(node, report.getReport()));
    getElementsFromDocument(doc, springConfigInMuleConfig.getAppliedTo().getExpression()).forEach(node -> springConfigInMuleConfig.execute(node, report.getReport()));
    getElementsFromDocument(doc, springBeans.getAppliedTo().getExpression()).forEach(node -> springBeans.execute(node, report.getReport()));
    getElementsFromDocument(doc, springContext.getAppliedTo().getExpression()).forEach(node -> springContext.execute(node, report.getReport()));
    getElementsFromDocument(doc, springContributions.getAppliedTo().getExpression()).forEach(node -> springContributions.execute(node, report.getReport()));
    XMLOutputter muleOutputter = new XMLOutputter(Format.getPrettyFormat());
    String muleXmlString = muleOutputter.outputString(doc);
    assertThat(muleXmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetMulePath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
    Document springDoc = appModel.getApplicationDocuments().get(Paths.get("src/main/resources/spring", targetSpringPath.getFileName().toString()));
    if (this.getClass().getClassLoader().getResource(targetSpringPath.toString()) != null) {
        XMLOutputter springOutputter = new XMLOutputter(Format.getPrettyFormat());
        String springXmlString = springOutputter.outputString(springDoc);
        assertThat(springXmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetSpringPath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
    } else {
        assertThat(springDoc, nullValue());
    }
}
Also used : Path(java.nio.file.Path) XMLOutputter(org.jdom2.output.XMLOutputter) ApplicationModelBuilder(com.mulesoft.tools.migration.project.model.ApplicationModel.ApplicationModelBuilder) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) Document(org.jdom2.Document) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument) Test(org.junit.Test)

Example 33 with Document

use of com.google.firestore.v1beta1.Document in project mule-migration-assistant by mulesoft.

the class ScriptingModuleMigrationTest method executeScriptWithRuby.

@Test
public void executeScriptWithRuby() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(SCRIPTING_SAMPLE_PATH.toString()).toURI().getPath());
    node = getElementsFromDocument(doc, scriptingModuleMigration.getAppliedTo().getExpression()).get(4);
    scriptingModuleMigration.execute(node, report.getReport());
    assertThat("The name didn't change.", node.getName(), equalTo("execute"));
    assertThat("The file attribute wasn't moved.", node.getAttribute("engine").getValue(), equalTo("ruby"));
}
Also used : 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 34 with Document

use of com.google.firestore.v1beta1.Document in project mule-migration-assistant by mulesoft.

the class ScriptingModuleMigrationTest method executeScriptWithCode.

@Test
public void executeScriptWithCode() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(SCRIPTING_SAMPLE_PATH.toString()).toURI().getPath());
    node = getElementsFromDocument(doc, scriptingModuleMigration.getAppliedTo().getExpression()).get(2);
    scriptingModuleMigration.execute(node, report.getReport());
    assertThat("The name didn't change.", node.getName(), equalTo("execute"));
    assertThat("The file attribute wasn't moved.", node.getAttribute("engine").getValue(), equalTo("nashorn"));
}
Also used : 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 35 with Document

use of com.google.firestore.v1beta1.Document in project mule-migration-assistant by mulesoft.

the class ScriptingModuleMigrationTest method executeScriptWithGroovyCode.

@Test
public void executeScriptWithGroovyCode() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(SCRIPTING_SAMPLE_PATH.toString()).toURI().getPath());
    node = getElementsFromDocument(doc, scriptingModuleMigration.getAppliedTo().getExpression()).get(3);
    scriptingModuleMigration.execute(node, report.getReport());
    assertThat("The name didn't change.", node.getName(), equalTo("execute"));
    assertThat("The file attribute wasn't moved.", node.getAttribute("engine").getValue(), equalTo("groovy"));
}
Also used : 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)

Aggregations

Document (org.jdom2.Document)1034 Element (org.jdom2.Element)587 Test (org.junit.Test)340 SAXBuilder (org.jdom2.input.SAXBuilder)271 IOException (java.io.IOException)266 XMLOutputter (org.jdom2.output.XMLOutputter)182 JDOMException (org.jdom2.JDOMException)162 File (java.io.File)148 ArrayList (java.util.ArrayList)75 InputStream (java.io.InputStream)74 StringReader (java.io.StringReader)63 Path (java.nio.file.Path)59 HashMap (java.util.HashMap)58 DocumentHelper.getDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getDocument)53 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument)53 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)48 PID (edu.unc.lib.boxc.model.api.ids.PID)47 Attribute (org.jdom2.Attribute)44 List (java.util.List)42 Namespace (org.jdom2.Namespace)39