Search in sources :

Example 6 with GPathResult

use of groovy.util.slurpersupport.GPathResult in project rest-assured by rest-assured.

the class XmlPath method prettyPeek.

/**
 * Peeks into the XML/HTML that XmlPath will parse by printing it to the console in a prettified manner. You can
 * continue working with XmlPath afterwards. This is mainly for debug purposes. If you want to return a prettified version of the content
 * see {@link #prettify()}. If you want to return a prettified version of the content and also print it to the console use {@link #prettyPrint()}.
 * <p/>
 * <p>
 * Note that the content is not guaranteed to be looking exactly like the it does at the source. This is because once you peek
 * the content has been downloaded and transformed into another data structure (used by XmlPath) and the XML is rendered
 * from this data structure.
 * </p>
 *
 * @return The same XmlPath instance
 */
public XmlPath prettyPeek() {
    final GPathResult result = lazyXmlParser.invoke();
    final String prettify = XmlPrettifier.prettify(result);
    System.out.println(prettify);
    return this;
}
Also used : GPathResult(groovy.util.slurpersupport.GPathResult)

Example 7 with GPathResult

use of groovy.util.slurpersupport.GPathResult in project rest-assured by rest-assured.

the class XmlPath method getFromPath.

private <T> T getFromPath(String path, boolean convertToJavaObject) {
    final GPathResult input = lazyXmlParser.invoke();
    final XMLAssertion xmlAssertion = new XMLAssertion();
    if (params != null) {
        xmlAssertion.setParams(params);
    }
    final String root = rootPath.equals("") ? rootPath : rootPath.endsWith(".") ? rootPath : rootPath + ".";
    xmlAssertion.setKey(root + path);
    return (T) xmlAssertion.getResult(input, convertToJavaObject, true);
}
Also used : XMLAssertion(io.restassured.assertion.XMLAssertion) GPathResult(groovy.util.slurpersupport.GPathResult)

Aggregations

GPathResult (groovy.util.slurpersupport.GPathResult)7 Binding (groovy.lang.Binding)3 XmlSlurper (groovy.util.XmlSlurper)3 IOException (java.io.IOException)3 MbengException (com.qwest.mbeng.MbengException)2 JsonSlurper (groovy.json.JsonSlurper)2 Closure (groovy.lang.Closure)2 GroovyShell (groovy.lang.GroovyShell)2 Writable (groovy.lang.Writable)2 CharArrayWriter (java.io.CharArrayWriter)2 File (java.io.File)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 JSONObject (org.json.JSONObject)2 GroovityConstants (com.disney.groovity.GroovityConstants)1 Taggable (com.disney.groovity.Taggable)1 Attr (com.disney.groovity.doc.Attr)1 Tag (com.disney.groovity.doc.Tag)1