Search in sources :

Example 31 with XPath

use of org.jdom2.xpath.XPath in project qpp-conversion-tool by CMSgov.

the class JsonPathToXpathHelper method executeAttributeTest.

public void executeAttributeTest(String jsonPath, String expectedValue) {
    String xPath = PathCorrelator.prepPath(jsonPath, wrapper);
    Attribute attribute = null;
    try {
        attribute = evaluateXpath(xPath, Filters.attribute());
    } catch (XmlException e) {
        fail(e.getMessage());
    }
    if (CHECK_FOR_NULL_SET.stream().anyMatch(jsonPath::matches)) {
        assertThat(attribute.getValue()).isNotNull();
    } else {
        assertWithMessage("( %s ) value ( %s ) does not equal ( %s ) at \n( %s ). \nPlease investigate.", jsonPath, expectedValue, attribute.getValue(), xPath).that(attribute.getValue()).isEqualTo(expectedValue);
    }
}
Also used : Attribute(org.jdom2.Attribute) XmlException(gov.cms.qpp.conversion.xml.XmlException)

Example 32 with XPath

use of org.jdom2.xpath.XPath in project qpp-conversion-tool by CMSgov.

the class JsonPathToXpathHelper method executeElementTest.

public void executeElementTest(String jsonPath, String xmlElementName) throws XmlException {
    String xPath = PathCorrelator.prepPath(jsonPath, wrapper);
    Element element = evaluateXpath(xPath, Filters.element());
    assertThat(xmlElementName).isEqualTo(element.getName());
}
Also used : Element(org.jdom2.Element)

Aggregations

Element (org.jdom2.Element)24 Document (org.jdom2.Document)11 IOException (java.io.IOException)4 Attribute (org.jdom2.Attribute)4 JDOMException (org.jdom2.JDOMException)4 MCRException (org.mycore.common.MCRException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 URISyntaxException (java.net.URISyntaxException)3 Text (org.jdom2.Text)3 XPath (org.jdom2.xpath.XPath)3 XPathFactory (org.jdom2.xpath.XPathFactory)3 MCRNodeBuilder (org.mycore.common.xml.MCRNodeBuilder)3 MCRObject (org.mycore.datamodel.metadata.MCRObject)3 XmlException (gov.cms.qpp.conversion.xml.XmlException)2 List (java.util.List)2 TransformerException (javax.xml.transform.TransformerException)2 XPath (javax.xml.xpath.XPath)2 MCRPersistenceException (org.mycore.common.MCRPersistenceException)2 MCRPath (org.mycore.datamodel.niofs.MCRPath)2 MCRPersistentIdentifierException (org.mycore.pi.exceptions.MCRPersistentIdentifierException)2