Search in sources :

Example 1 with XmlException

use of gov.cms.qpp.conversion.xml.XmlException in project qpp-conversion-tool by CMSgov.

the class AciMeasurePerformedRnRDecoderTest method testUpperLevel.

@Test
void testUpperLevel() throws XmlException, IOException {
    String needsFormattingXml = TestHelper.getFixture("AciMeasurePerformedIsolated.xml");
    String xml = String.format(needsFormattingXml, MEASURE_ID);
    Node wrapperNode = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xml));
    Node aciMeasurePerformedNode = wrapperNode.getChildNodes().get(0);
    String actualMeasureId = aciMeasurePerformedNode.getValue("measureId");
    assertThat(actualMeasureId).isEqualTo(MEASURE_ID);
    long measurePerformedCount = aciMeasurePerformedNode.getChildNodes(node -> node.getType() == TemplateId.MEASURE_PERFORMED).count();
    assertThat(measurePerformedCount).isEqualTo(1L);
}
Also used : Context(gov.cms.qpp.conversion.Context) Test(org.junit.jupiter.api.Test) Context(gov.cms.qpp.conversion.Context) TestHelper(gov.cms.qpp.TestHelper) Node(gov.cms.qpp.conversion.model.Node) XmlUtils(gov.cms.qpp.conversion.xml.XmlUtils) Namespace(org.jdom2.Namespace) TemplateId(gov.cms.qpp.conversion.model.TemplateId) IOException(java.io.IOException) XmlException(gov.cms.qpp.conversion.xml.XmlException) Truth.assertThat(com.google.common.truth.Truth.assertThat) Element(org.jdom2.Element) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 2 with XmlException

use of gov.cms.qpp.conversion.xml.XmlException in project qpp-conversion-tool by CMSgov.

the class ValidationApiAcceptance method verifyDetail.

private void verifyDetail(Detail detail) {
    String xPath = detail.getPath();
    Filter filter = xPath.contains("@") ? Filters.attribute() : Filters.element();
    try {
        Object found = evaluateXpath(detail.getPath(), filter);
        if (filter.equals(Filters.attribute())) {
            Attribute attribute = (Attribute) found;
            assertThat(attribute.getIntValue()).isEqualTo(CANNED_VALUE);
            assertThat(detail.getMessage()).startsWith(ValidationServiceImpl.SV_LABEL);
        } else {
            assertThat(found).isNotNull();
        }
    } catch (XmlException | DataConversionException ex) {
        fail("This xpath could not be found: " + detail.getPath(), ex);
    }
}
Also used : Filter(org.jdom2.filter.Filter) Attribute(org.jdom2.Attribute) XmlException(gov.cms.qpp.conversion.xml.XmlException) DataConversionException(org.jdom2.DataConversionException)

Example 3 with XmlException

use of gov.cms.qpp.conversion.xml.XmlException 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)

Aggregations

XmlException (gov.cms.qpp.conversion.xml.XmlException)3 Attribute (org.jdom2.Attribute)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 TestHelper (gov.cms.qpp.TestHelper)1 Context (gov.cms.qpp.conversion.Context)1 Node (gov.cms.qpp.conversion.model.Node)1 TemplateId (gov.cms.qpp.conversion.model.TemplateId)1 XmlUtils (gov.cms.qpp.conversion.xml.XmlUtils)1 IOException (java.io.IOException)1 DataConversionException (org.jdom2.DataConversionException)1 Element (org.jdom2.Element)1 Namespace (org.jdom2.Namespace)1 Filter (org.jdom2.filter.Filter)1 Test (org.junit.jupiter.api.Test)1