Search in sources :

Example 26 with Document

use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project mule-migration-assistant by mulesoft.

the class MetadataTest method execute.

@Test
public void execute() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
    getElementsFromDocument(doc, setPayload.getAppliedTo().getExpression()).forEach(node -> setPayload.execute(node, report.getReport()));
    getElementsFromDocument(doc, dwTransform.getAppliedTo().getExpression()).forEach(node -> dwTransform.execute(node, report.getReport()));
    getElementsFromDocument(doc, metadata.getAppliedTo().getExpression()).forEach(node -> metadata.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 27 with Document

use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project mule-migration-assistant by mulesoft.

the class PollTest method execute.

@Test
public void execute() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
    getElementsFromDocument(doc, poll.getAppliedTo().getExpression()).forEach(node -> poll.execute(node, report.getReport()));
    getElementsFromDocument(doc, removeSyntheticMigrationAttributes.getAppliedTo().getExpression()).forEach(node -> removeSyntheticMigrationAttributes.execute(node, report.getReport()));
    getElementsFromDocument(doc, keepElementsAtBottomOfFlow.getAppliedTo().getExpression()).forEach(node -> keepElementsAtBottomOfFlow.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.forgerock.openbanking.common.model.openbanking.obie.pain00200109.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 29 with Document

use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.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 30 with Document

use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.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)

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