Search in sources :

Example 6 with QrdaDecoderEngine

use of gov.cms.qpp.conversion.decode.QrdaDecoderEngine in project qpp-conversion-tool by CMSgov.

the class CpcMeasureDataValidatorTest method validateFailureSupplementalDataMissingCountTest.

@Test
void validateFailureSupplementalDataMissingCountTest() throws Exception {
    String failurePayerFile = TestHelper.getFixture("failureSupplementalDataCountFile.xml");
    Node placeholder = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(failurePayerFile));
    CpcMeasureDataValidator validator = new CpcMeasureDataValidator();
    Node underTest = placeholder.findFirstNode(TemplateId.MEASURE_DATA_CMS_V2);
    validator.internalValidateSingleNode(underTest);
    LocalizedError expectedError = ErrorCode.CPC_PLUS_SUPPLEMENTAL_DATA_MISSING_COUNT.format(SupplementalData.MALE.getCode(), SubPopulationLabel.IPOP.name(), MEASURE_ID);
    Set<Detail> errors = validator.getDetails();
    assertThat(errors).comparingElementsUsing(DetailsErrorEquals.INSTANCE).contains(expectedError);
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) LocalizedError(gov.cms.qpp.conversion.model.error.LocalizedError) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with QrdaDecoderEngine

use of gov.cms.qpp.conversion.decode.QrdaDecoderEngine in project qpp-conversion-tool by CMSgov.

the class CpcMeasureDataValidatorTest method validateSuccessfulSupplementalDataFieldsTest.

@Test
void validateSuccessfulSupplementalDataFieldsTest() throws Exception {
    String successfulFile = TestHelper.getFixture("successfulSupplementalDataFile.xml");
    Node placeholder = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(successfulFile));
    CpcMeasureDataValidator validator = new CpcMeasureDataValidator();
    Node underTest = placeholder.findFirstNode(TemplateId.MEASURE_DATA_CMS_V2);
    validator.internalValidateSingleNode(underTest);
    Set<Detail> errors = validator.getDetails();
    assertThat(errors).isEmpty();
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with QrdaDecoderEngine

use of gov.cms.qpp.conversion.decode.QrdaDecoderEngine in project qpp-conversion-tool by CMSgov.

the class DefaultDecoderTest method parseAllNodes.

@Test
void parseAllNodes() throws Exception {
    InputStream stream = NioHelper.fileToStream(Paths.get("../qrda-files/valid-QRDA-III.xml"));
    String xmlFragment = IOUtils.toString(stream, StandardCharsets.UTF_8);
    Node node = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlFragment));
    assertThat(node).isNotNull();
}
Also used : Context(gov.cms.qpp.conversion.Context) InputStream(java.io.InputStream) Node(gov.cms.qpp.conversion.model.Node) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Test(org.junit.jupiter.api.Test)

Example 9 with QrdaDecoderEngine

use of gov.cms.qpp.conversion.decode.QrdaDecoderEngine in project qpp-conversion-tool by CMSgov.

the class DefaultEncoderTest method encodeAllNodes.

@Test
void encodeAllNodes() throws Exception {
    InputStream stream = NioHelper.fileToStream(Paths.get("../qrda-files/valid-QRDA-III.xml"));
    String xmlFragment = IOUtils.toString(stream, StandardCharsets.UTF_8);
    Node node = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlFragment));
    Node placeHolder = new Node(TemplateId.DEFAULT, node);
    node.addChildNode(placeHolder);
    JsonWrapper wrapper = new JsonWrapper();
    new QppOutputEncoder(new Context()).encode(wrapper, node);
    assertThat(wrapper.toString().length() > 10).isTrue();
}
Also used : Context(gov.cms.qpp.conversion.Context) JsonWrapper(gov.cms.qpp.conversion.encode.JsonWrapper) QppOutputEncoder(gov.cms.qpp.conversion.encode.QppOutputEncoder) InputStream(java.io.InputStream) Node(gov.cms.qpp.conversion.model.Node) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Test(org.junit.jupiter.api.Test)

Example 10 with QrdaDecoderEngine

use of gov.cms.qpp.conversion.decode.QrdaDecoderEngine in project qpp-conversion-tool by CMSgov.

the class MeasureDataValidatorTest method internalValidateSingleNode.

@Test
void internalValidateSingleNode() throws Exception {
    String happy = TestHelper.getFixture("measureDataHappy.xml");
    Node placeholder = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(happy));
    MeasureDataValidator validator = new MeasureDataValidator();
    Node underTest = placeholder.findFirstNode(TemplateId.MEASURE_DATA_CMS_V2);
    validator.internalValidateSingleNode(underTest);
    Set<Detail> errors = validator.getDetails();
    assertWithMessage("Expect no errors on the happy path").that(errors).isEmpty();
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Aggregations

Context (gov.cms.qpp.conversion.Context)14 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)14 Node (gov.cms.qpp.conversion.model.Node)14 Test (org.junit.jupiter.api.Test)13 QppOutputEncoder (gov.cms.qpp.conversion.encode.QppOutputEncoder)6 StringWriter (java.io.StringWriter)6 BufferedWriter (java.io.BufferedWriter)5 ArrayList (java.util.ArrayList)5 Detail (gov.cms.qpp.conversion.model.error.Detail)3 InputStream (java.io.InputStream)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 JsonWrapper (gov.cms.qpp.conversion.encode.JsonWrapper)1 LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)1