Search in sources :

Example 81 with Context

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

the class SupplementalDataPayerDecoderTest method decodeNodeFromFile.

private void decodeNodeFromFile(String filename) throws XmlException {
    context = new Context();
    SupplementalDataPayerDecoder decoder = new SupplementalDataPayerDecoder(context);
    QrdaDecoderEngine engine = new QrdaDecoderEngine(context);
    root = engine.decode(XmlUtils.stringToDom(filename));
}
Also used : Context(gov.cms.qpp.conversion.Context)

Example 82 with Context

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

the class SupplementalDataRaceDecoderTest method decodeNodeFromFile.

private void decodeNodeFromFile(String filename) throws XmlException {
    context = new Context();
    SupplementalDataRaceDecoder decoder = new SupplementalDataRaceDecoder(context);
    QrdaDecoderEngine engine = new QrdaDecoderEngine(context);
    root = engine.decode(XmlUtils.stringToDom(filename));
}
Also used : Context(gov.cms.qpp.conversion.Context)

Example 83 with Context

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

the class AciMeasurePerformedRnREncoderTest method testInternalEncodeBooleanStringValue.

@Test
void testInternalEncodeBooleanStringValue() {
    // set-up
    JsonWrapper jsonWrapper = new JsonWrapper();
    AciMeasurePerformedRnREncoder objectUnderTest = new AciMeasurePerformedRnREncoder(new Context());
    String unknownValue = "Some unknown value";
    aciMeasurePerformedRnR.getChildNodes().get(0).putValue("measurePerformed", unknownValue);
    // execute
    objectUnderTest.internalEncode(jsonWrapper, aciMeasurePerformedRnR);
    // assert
    assertThat(jsonWrapper.getString("measureId")).isEqualTo(MEASURE_ID);
    assertThat(jsonWrapper.getString("value")).isEqualTo(unknownValue);
}
Also used : Context(gov.cms.qpp.conversion.Context) Test(org.junit.jupiter.api.Test)

Example 84 with Context

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

the class AciNumeratorDenominatorEncoderTest method testEncoder.

@Test
void testEncoder() {
    QppOutputEncoder encoder = new QppOutputEncoder(new Context());
    encoder.setNodes(nodes);
    StringWriter sw = new StringWriter();
    try {
        encoder.encode(new BufferedWriter(sw));
    } catch (EncodeException e) {
        Assertions.fail("Failure to encode: " + e.getMessage());
    }
    String EXPECTED = "{\n  \"measureId\" : \"" + MEASURE_ID + "\",\n  \"value\" : {\n    \"numerator\" : 400,\n    \"denominator\" : 600\n  }\n}";
    assertThat(sw.toString()).isEqualTo(EXPECTED);
}
Also used : Context(gov.cms.qpp.conversion.Context) StringWriter(java.io.StringWriter) BufferedWriter(java.io.BufferedWriter) Test(org.junit.jupiter.api.Test)

Example 85 with Context

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

the class AciNumeratorDenominatorEncoderTest method testNoChildEncoder.

@Test
void testNoChildEncoder() throws EncodeException {
    JsonWrapper jsonWrapper = new JsonWrapper();
    AciNumeratorDenominatorEncoder objectUnderTest = new AciNumeratorDenominatorEncoder(new Context());
    Node unknownNode = new Node();
    aciProportionMeasureNode.addChildNode(unknownNode);
    // execute
    objectUnderTest.internalEncode(jsonWrapper, aciProportionMeasureNode);
    // assert
    assertThat(objectUnderTest.getDetails()).hasSize(1);
    assertWithMessage("The validation error must be the inability to find an encoder").that(objectUnderTest.getDetails().get(0).getMessage()).isEqualTo(ErrorCode.CT_LABEL + "Failed to find an encoder");
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Aggregations

Context (gov.cms.qpp.conversion.Context)114 Test (org.junit.jupiter.api.Test)92 Node (gov.cms.qpp.conversion.model.Node)63 BufferedWriter (java.io.BufferedWriter)17 StringWriter (java.io.StringWriter)17 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)14 Element (org.jdom2.Element)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 QppOutputEncoder (gov.cms.qpp.conversion.encode.QppOutputEncoder)8 ArrayList (java.util.ArrayList)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 TemplateId (gov.cms.qpp.conversion.model.TemplateId)4 Detail (gov.cms.qpp.conversion.model.error.Detail)4 InputStream (java.io.InputStream)4 Namespace (org.jdom2.Namespace)4 Map (java.util.Map)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 Converter (gov.cms.qpp.conversion.Converter)2 PathSource (gov.cms.qpp.conversion.PathSource)2 ComponentKey (gov.cms.qpp.conversion.model.ComponentKey)2