Search in sources :

Example 26 with Converter

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

the class IaSectionRoundTripTest method testIaSectionConvertsIaCategory.

@Test
void testIaSectionConvertsIaCategory() {
    Converter converter = new Converter(new PathSource(file));
    JsonWrapper qpp = converter.transform();
    String iaCategory = JsonHelper.readJsonAtJsonPath(qpp.toString(), "$.measurementSets[2].category", String.class);
    assertWithMessage("Must contain a category").that(iaCategory).isEqualTo("ia");
}
Also used : JsonWrapper(gov.cms.qpp.conversion.encode.JsonWrapper) PathSource(gov.cms.qpp.conversion.PathSource) Converter(gov.cms.qpp.conversion.Converter) Test(org.junit.jupiter.api.Test)

Example 27 with Converter

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

the class IaSectionRoundTripTest method testIaSectionConvertsMeasurePerformed.

@Test
void testIaSectionConvertsMeasurePerformed() {
    Converter converter = new Converter(new PathSource(file));
    JsonWrapper qpp = converter.transform();
    Boolean measurePerformed = JsonHelper.readJsonAtJsonPath(qpp.toString(), "$.measurementSets[2].measurements[0].value", Boolean.class);
    assertWithMessage("Must contain a measure performed").that(measurePerformed).isTrue();
}
Also used : JsonWrapper(gov.cms.qpp.conversion.encode.JsonWrapper) PathSource(gov.cms.qpp.conversion.PathSource) Converter(gov.cms.qpp.conversion.Converter) Test(org.junit.jupiter.api.Test)

Example 28 with Converter

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

the class IaSectionValidatorRoundTripTest method testIaSectionValidatorMissingReportingParameters.

@Test
void testIaSectionValidatorMissingReportingParameters() {
    Path path = Paths.get("src/test/resources/negative/iaSectionMissingReportingParameter.xml");
    Converter converter = new Converter(new PathSource(path));
    AllErrors errors = new AllErrors();
    try {
        converter.transform();
        Assertions.fail("Should not reach");
    } catch (TransformException exception) {
        errors = exception.getDetails();
    }
    Integer error = errors.getErrors().get(0).getDetails().get(0).getErrorCode();
    assertThat(ErrorCode.getByCode(error)).isEqualTo(ErrorCode.IA_SECTION_MISSING_REPORTING_PARAM);
}
Also used : Path(java.nio.file.Path) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) PathSource(gov.cms.qpp.conversion.PathSource) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Converter(gov.cms.qpp.conversion.Converter) Test(org.junit.jupiter.api.Test)

Example 29 with Converter

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

the class IaSectionValidatorRoundTripTest method testIaSectionValidatorMissingMeasures.

@Test
void testIaSectionValidatorMissingMeasures() {
    Path path = Paths.get("src/test/resources/negative/iaSectionMissingMeasures.xml");
    Converter converter = new Converter(new PathSource(path));
    AllErrors errors = new AllErrors();
    try {
        converter.transform();
    } catch (TransformException exception) {
        errors = exception.getDetails();
    }
    Integer error = errors.getErrors().get(0).getDetails().get(0).getErrorCode();
    assertThat(ErrorCode.getByCode(error)).isEqualTo(ErrorCode.IA_SECTION_MISSING_IA_MEASURE);
}
Also used : Path(java.nio.file.Path) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) PathSource(gov.cms.qpp.conversion.PathSource) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Converter(gov.cms.qpp.conversion.Converter) Test(org.junit.jupiter.api.Test)

Example 30 with Converter

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

the class IaSectionValidatorRoundTripTest method testIaSectionValidatorIncorrectChildren.

@Test
void testIaSectionValidatorIncorrectChildren() {
    Path path = Paths.get("src/test/resources/negative/iaSectionContainsWrongChild.xml");
    Context context = new Context();
    context.setDoDefaults(true);
    Converter converter = new Converter(new PathSource(path), context);
    AllErrors errors = new AllErrors();
    try {
        converter.transform();
    } catch (TransformException exception) {
        errors = exception.getDetails();
    }
    Integer error = errors.getErrors().get(0).getDetails().get(0).getErrorCode();
    assertThat(ErrorCode.getByCode(error)).isEqualTo(ErrorCode.IA_SECTION_WRONG_CHILD);
}
Also used : Path(java.nio.file.Path) Context(gov.cms.qpp.conversion.Context) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) PathSource(gov.cms.qpp.conversion.PathSource) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Converter(gov.cms.qpp.conversion.Converter) Test(org.junit.jupiter.api.Test)

Aggregations

Converter (gov.cms.qpp.conversion.Converter)34 PathSource (gov.cms.qpp.conversion.PathSource)28 Test (org.junit.jupiter.api.Test)18 TransformException (gov.cms.qpp.conversion.model.error.TransformException)16 AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)15 JsonWrapper (gov.cms.qpp.conversion.encode.JsonWrapper)9 Detail (gov.cms.qpp.conversion.model.error.Detail)9 Path (java.nio.file.Path)9 ArrayList (java.util.ArrayList)6 BeforeAll (org.junit.jupiter.api.BeforeAll)4 Map (java.util.Map)3 Context (gov.cms.qpp.conversion.Context)2 ConversionReport (gov.cms.qpp.conversion.ConversionReport)2 InputStreamSupplierSource (gov.cms.qpp.conversion.InputStreamSupplierSource)2 LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)2 InputStream (java.io.InputStream)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1