Search in sources :

Example 26 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.Document in project mule-migration-assistant by mulesoft.

the class PreprocessNamespacesTest method execute.

@Test
public void execute() throws Exception {
    preprocessNamespaces.execute(applicationModel, report.getReport());
    Document document = Iterables.get(applicationModel.getApplicationDocuments().values(), 0);
    assertThat("The namespace was removed.", document.getRootElement().getAdditionalNamespaces().size(), is(3));
}
Also used : Document(org.jdom2.Document) DocumentHelper.getDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getDocument) Test(org.junit.Test)

Example 27 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.Document in project mule-migration-assistant by mulesoft.

the class ProcessorChainReferenceTest method execute.

@Test
public void execute() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
    getElementsFromDocument(doc, processorChain.getAppliedTo().getExpression()).forEach(node -> processorChain.execute(node, report.getReport()));
    getElementsFromDocument(doc, processorChainReference.getAppliedTo().getExpression()).forEach(node -> processorChainReference.execute(node, report.getReport()));
    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 : XMLOutputter(org.jdom2.output.XMLOutputter) 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 28 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.Document in project mule-migration-assistant by mulesoft.

the class ApplicationModel method getNodes.

/**
 * Returns all the nodes in the application documents that match the xpath expression
 *
 * @param xpathExpression the xpath expression that defines which nodes should be retrieved
 * @return all the nodes that match the xpath expression
 */
public List<Element> getNodes(XPathExpression xpathExpression) {
    checkArgument(xpathExpression != null, "The Xpath Expression must not be null nor empty");
    List<Element> nodes = new LinkedList<>();
    for (Document doc : getApplicationDocuments().values()) {
        nodes.addAll(getElementsFromDocument(xpathExpression, doc));
    }
    for (Document doc : getDomainDocuments().values()) {
        nodes.addAll(getElementsFromDocument(xpathExpression, doc));
    }
    return nodes;
}
Also used : Element(org.jdom2.Element) XmlDslUtils.generateDocument(com.mulesoft.tools.migration.step.util.XmlDslUtils.generateDocument) Document(org.jdom2.Document) LinkedList(java.util.LinkedList)

Example 29 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.Document in project mule-migration-assistant by mulesoft.

the class XmlToDomTransformerTest method execute.

@Test
public void execute() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
    getElementsFromDocument(doc, xmlToDomTransformer.getAppliedTo().getExpression()).forEach(node -> xmlToDomTransformer.execute(node, report.getReport()));
    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());
    report.expectReportEntry("mulexml.xmlToDom");
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) 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 30 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.Document in project mule-migration-assistant by mulesoft.

the class AssertFalseTest method execute.

@Test
public void execute() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(MUNIT_SAMPLE_PATH.toString()).toURI().getPath());
    node = getElementsFromDocument(doc, assertFalse.getAppliedTo().getExpression()).get(0);
    assertFalse.execute(node, report.getReport());
    assertThat("The node didn't change", node.getName(), is("assert-that"));
    assertThat("The attribute didn't change", node.getAttribute("is"), is(notNullValue()));
    assertThat("The attribute didn't change", node.getAttribute("is").getValue(), is("#[MunitTools::equalTo(false)]"));
}
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)57 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