Search in sources :

Example 21 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.

the class ConverterTest method testEncodingExceptions.

@Test
@PrepareForTest({ Converter.class, QppOutputEncoder.class })
public void testEncodingExceptions() throws Exception {
    QppOutputEncoder encoder = mock(QppOutputEncoder.class);
    whenNew(QppOutputEncoder.class).withAnyArguments().thenReturn(encoder);
    EncodeException ex = new EncodeException("mocked", new RuntimeException());
    doThrow(ex).when(encoder).encode();
    Path path = Paths.get("src/test/resources/converter/defaultedNode.xml");
    Converter converter = new Converter(new PathSource(path));
    converter.getContext().setDoDefaults(false);
    converter.getContext().setDoValidation(false);
    try {
        converter.transform();
        fail();
    } catch (TransformException exception) {
        checkup(exception, ErrorCode.NOT_VALID_XML_DOCUMENT);
    }
}
Also used : Path(java.nio.file.Path) QppOutputEncoder(gov.cms.qpp.conversion.encode.QppOutputEncoder) TransformException(gov.cms.qpp.conversion.model.error.TransformException) EncodeException(gov.cms.qpp.conversion.encode.EncodeException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 22 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException 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 23 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException 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 24 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException 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)

Example 25 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.

the class QualityMeasureIdMultiRoundTripTest method executeScenario.

private List<Detail> executeScenario(String path, boolean remove) {
    InputStream modified = manipulator.upsetTheNorm(path, remove);
    Converter converter = new Converter(new InputStreamSupplierSource(JUNK_QRDA3_FILE.toString(), modified));
    List<Detail> details = new ArrayList<>();
    try {
        converter.transform();
    } catch (TransformException exception) {
        AllErrors errors = exception.getDetails();
        details.addAll(errors.getErrors().get(0).getDetails());
    }
    return details;
}
Also used : InputStream(java.io.InputStream) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) ArrayList(java.util.ArrayList) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Converter(gov.cms.qpp.conversion.Converter) InputStreamSupplierSource(gov.cms.qpp.conversion.InputStreamSupplierSource) Detail(gov.cms.qpp.conversion.model.error.Detail)

Aggregations

TransformException (gov.cms.qpp.conversion.model.error.TransformException)27 AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)21 Test (org.junit.jupiter.api.Test)17 Converter (gov.cms.qpp.conversion.Converter)16 PathSource (gov.cms.qpp.conversion.PathSource)13 Path (java.nio.file.Path)10 Detail (gov.cms.qpp.conversion.model.error.Detail)9 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 Context (gov.cms.qpp.conversion.Context)2 InputStreamSupplierSource (gov.cms.qpp.conversion.InputStreamSupplierSource)2 LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)2 InputStream (java.io.InputStream)2 List (java.util.List)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 ConversionReport (gov.cms.qpp.conversion.ConversionReport)1