Search in sources :

Example 26 with Context

use of gov.cms.qpp.conversion.Context 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 27 with Context

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

the class DefaultDecoderTest method testInternalDecode.

@Test
void testInternalDecode() {
    DefaultDecoder decoder = new DefaultDecoder(new Context(), "mock");
    Node node = new Node();
    decoder.decode(null, node);
    Truth.assertThat(node.getValue("DefaultDecoderFor")).isEqualTo("mock");
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 28 with Context

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

the class AciMeasurePerformedRnREncoderTest method testEncoder.

@Test
@SuppressWarnings("unchecked")
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());
    }
    Map<String, Object> content = JsonHelper.readJson(new ByteArrayInputStream(sw.toString().getBytes()), Map.class);
    assertThat(content.get("measureId")).isEqualTo(MEASURE_ID);
    assertThat(content.get("value")).isEqualTo(true);
}
Also used : Context(gov.cms.qpp.conversion.Context) StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedWriter(java.io.BufferedWriter) Test(org.junit.jupiter.api.Test)

Example 29 with Context

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

the class AciMeasurePerformedRnREncoderTest method testInternalEncodeNoChildNoValue.

@Test
void testInternalEncodeNoChildNoValue() {
    // set-up
    JsonWrapper jsonWrapper = new JsonWrapper();
    AciMeasurePerformedRnREncoder objectUnderTest = new AciMeasurePerformedRnREncoder(new Context());
    aciMeasurePerformedRnR.setChildNodes();
    // execute
    objectUnderTest.internalEncode(jsonWrapper, aciMeasurePerformedRnR);
    // assert
    assertThat(jsonWrapper.getString("measureId")).isEqualTo(MEASURE_ID);
    assertThat(jsonWrapper.getBoolean("value")).isNull();
}
Also used : Context(gov.cms.qpp.conversion.Context) Test(org.junit.jupiter.api.Test)

Example 30 with Context

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

the class AciMeasurePerformedRnREncoderTest method testInternalEncode.

@Test
void testInternalEncode() {
    // set-up
    JsonWrapper jsonWrapper = new JsonWrapper();
    AciMeasurePerformedRnREncoder objectUnderTest = new AciMeasurePerformedRnREncoder(new Context());
    // execute
    objectUnderTest.internalEncode(jsonWrapper, aciMeasurePerformedRnR);
    // assert
    assertThat(jsonWrapper.getString("measureId")).isEqualTo(MEASURE_ID);
    assertThat(jsonWrapper.getBoolean("value")).isEqualTo(true);
}
Also used : Context(gov.cms.qpp.conversion.Context) 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