Search in sources :

Example 16 with Document

use of com.google.cloud.dialogflow.v2beta1.Document in project mule-migration-assistant by mulesoft.

the class FirstSuccessfulTest method execute.

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

use of com.google.cloud.dialogflow.v2beta1.Document in project mule-migration-assistant by mulesoft.

the class RemoveObjectToStringTransformerTest method execute.

@Test
public void execute() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(FILE_SAMPLE_PATH.toString()).toURI().getPath());
    node = getElementsFromDocument(doc, removeObjectToStringTransformer.getAppliedTo().getExpression()).get(0);
    removeObjectToStringTransformer.execute(node, report.getReport());
    assertThat("The node wasn't remove.", node.getParent(), is(nullValue()));
}
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 18 with Document

use of com.google.cloud.dialogflow.v2beta1.Document in project mule-migration-assistant by mulesoft.

the class RemoveSyntheticMigrationAttributesTest method execute.

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

use of com.google.cloud.dialogflow.v2beta1.Document in project mule-migration-assistant by mulesoft.

the class SessionVariablesTest method execute.

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

use of com.google.cloud.dialogflow.v2beta1.Document in project mule-migration-assistant by mulesoft.

the class SetPropertyTest method execute.

@Test
public void execute() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(FILE_SAMPLE_PATH.toString()).toURI().getPath());
    node = getElementsFromDocument(doc, setProperty.getAppliedTo().getExpression()).get(0);
    setProperty.execute(node, report.getReport());
    assertThat("The node namespace didn't change", node.getNamespaceURI(), is("http://www.mulesoft.org/schema/mule/compatibility"));
    assertThat("The node namespace prefix didn't change", node.getNamespacePrefix(), is("compatibility"));
    assertThat("The node name changed", node.getName(), is("set-property"));
    assertThat("The attribute was renamed", node.getAttribute("propertyName"), is(notNullValue()));
}
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)342 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