Search in sources :

Example 46 with Context

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

the class AciSectionEncoderMultiMeasureTest 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 47 with Context

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

the class AciSectionEncoderTest method testInternalEncodeWithNoChildren.

@Test
void testInternalEncodeWithNoChildren() {
    JsonWrapper testWrapper = new JsonWrapper();
    Node invalidAciNumeratorDenominatorNode = new Node();
    aciSectionNode = new Node(TemplateId.ACI_SECTION);
    aciSectionNode.putValue(CATEGORY, ACI);
    aciSectionNode.addChildNode(invalidAciNumeratorDenominatorNode);
    aciSectionNode.addChildNode(reportingParametersNode);
    AciSectionEncoder aciSectionEncoder = new AciSectionEncoder(new Context());
    aciSectionEncoder.internalEncode(testWrapper, aciSectionNode);
    assertThat(aciSectionEncoder.getDetails()).isNotNull();
    assertThat(aciSectionEncoder.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)

Example 48 with Context

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

the class AciSectionEncoderTest method testInternalEncode.

@Test
void testInternalEncode() {
    JsonWrapper jsonWrapper = new JsonWrapper();
    AciSectionEncoder aciSectionEncoder = new AciSectionEncoder(new Context());
    aciSectionEncoder.internalEncode(jsonWrapper, aciSectionNode);
    Map<?, ?> testMapObject = (Map<?, ?>) jsonWrapper.getObject();
    assertWithMessage("Must have a child node").that(testMapObject).isNotNull();
    assertWithMessage("Must be category ACI").that(testMapObject.get(CATEGORY)).isEqualTo(ACI);
    assertWithMessage("Must have measurements").that(testMapObject.get(MEASUREMENTS)).isNotNull();
    assertWithMessage("Must have submissionMethod").that(testMapObject.get(SUBMISSION_METHOD)).isEqualTo(ELECTRONIC_HEALTH_RECORD);
}
Also used : Context(gov.cms.qpp.conversion.Context) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 49 with Context

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

the class ClinicalDocumentEncoderTest method testInternalEncodeNullEntityId.

@Test
void testInternalEncodeNullEntityId() throws EncodeException {
    clinicalDocumentNode.getChildNodes().remove(aciSectionNode);
    clinicalDocumentNode.putValue(ClinicalDocumentDecoder.ENTITY_ID, null);
    JsonWrapper testJsonWrapper = new JsonWrapper();
    ClinicalDocumentEncoder clinicalDocumentEncoder = new ClinicalDocumentEncoder(new Context());
    clinicalDocumentEncoder.internalEncode(testJsonWrapper, clinicalDocumentNode);
    Map<?, ?> clinicalDocMap = ((Map<?, ?>) testJsonWrapper.getObject());
    assertThat(clinicalDocMap.get(ClinicalDocumentDecoder.ENTITY_ID)).isNull();
}
Also used : Context(gov.cms.qpp.conversion.Context) Test(org.junit.jupiter.api.Test)

Example 50 with Context

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

the class ClinicalDocumentEncoderTest method testPerformanceYear.

@Test
void testPerformanceYear() {
    JsonWrapper testJsonWrapper = new JsonWrapper();
    ClinicalDocumentEncoder clinicalDocumentEncoder = new ClinicalDocumentEncoder(new Context());
    clinicalDocumentEncoder.internalEncode(testJsonWrapper, clinicalDocumentNode);
    Object performanceYear = testJsonWrapper.getValue(ReportingParametersActDecoder.PERFORMANCE_YEAR);
    assertThat(performanceYear).isEqualTo(2017);
}
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