Search in sources :

Example 51 with Context

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

the class EncoderNegativeConditionsTest method testNullEncoder.

@Test
void testNullEncoder() {
    QppOutputEncoder encoder = new QppOutputEncoder(new Context());
    Node aNode = new Node();
    aNode.putValue("something", "600");
    List<Node> nodes = new ArrayList<>();
    nodes.add(aNode);
    encoder.setNodes(nodes);
    StringWriter sw = new StringWriter();
    try {
        encoder.encode(new BufferedWriter(sw));
    } catch (EncodeException e) {
        Assertions.fail("Failure to encode: " + e.getMessage());
    }
    // NOTE: This test is only relevant in that it finds the deep value but
    // it is not actually a result
    String expected = "null";
    assertThat(sw.toString()).isEqualTo(expected);
}
Also used : Context(gov.cms.qpp.conversion.Context) StringWriter(java.io.StringWriter) Node(gov.cms.qpp.conversion.model.Node) ArrayList(java.util.ArrayList) BufferedWriter(java.io.BufferedWriter) Test(org.junit.jupiter.api.Test)

Example 52 with Context

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

the class EncoderNegativeConditionsTest method testExceptionAddsValidation.

@Test
void testExceptionAddsValidation() throws EncodeException {
    Node numeratorDenominatorNode;
    List<Node> nodes;
    numeratorDenominatorNode = new Node(TemplateId.ACI_AGGREGATE_COUNT);
    numeratorDenominatorNode.putValue("aggregateCount", "600");
    nodes = new ArrayList<>();
    nodes.add(numeratorDenominatorNode);
    QppOutputEncoder encoder = new QppOutputEncoder(new Context());
    encoder.setNodes(nodes);
    FailingWriter failWrite = new FailingWriter();
    encoder.encode(new BufferedWriter(failWrite));
    assertThat(encoder.getDetails()).hasSize(1);
    assertThat(encoder.getDetails().get(0).getMessage()).isEqualTo("Fake IOException");
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) BufferedWriter(java.io.BufferedWriter) Test(org.junit.jupiter.api.Test)

Example 53 with Context

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

the class IaSectionEncoderTest method testEncoderWithoutMeasure.

@Test
void testEncoderWithoutMeasure() {
    iaSectionNode.getChildNodes().remove(iaMeasureNode);
    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());
    }
    assertThat(sw.toString()).isEqualTo(EXPECTED_NO_MEASURE);
}
Also used : Context(gov.cms.qpp.conversion.Context) StringWriter(java.io.StringWriter) BufferedWriter(java.io.BufferedWriter) Test(org.junit.jupiter.api.Test)

Example 54 with Context

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

the class IaSectionEncoderTest 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());
    }
    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 55 with Context

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

the class NoArgThrowableConstructor method before.

@BeforeEach
void before() {
    context = new Context();
    registry = context.getRegistry(Decoder.class);
}
Also used : Context(gov.cms.qpp.conversion.Context) AggregateCountDecoder(gov.cms.qpp.conversion.decode.AggregateCountDecoder) QrdaDecoder(gov.cms.qpp.conversion.decode.QrdaDecoder) BeforeEach(org.junit.jupiter.api.BeforeEach)

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