Search in sources :

Example 16 with AllErrors

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

the class AggregateCountFailureTest method testInvalidAggregateCounts.

@Test
void testInvalidAggregateCounts() throws IOException {
    // execute
    Converter converter = new Converter(new PathSource(Paths.get("src/test/resources/negative/angerTheConverter.xml")));
    String errorContent = "";
    try {
        converter.transform();
        Assertions.fail("A transformation exception must have been thrown!");
    } catch (TransformException exception) {
        AllErrors errors = exception.getDetails();
        ObjectWriter jsonObjectWriter = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL).writer().withDefaultPrettyPrinter();
        errorContent = jsonObjectWriter.writeValueAsString(errors);
    }
    // assert
    assertWithMessage("The error file flags a aggregate count type error").that(errorContent).contains(ErrorCode.NUMERATOR_DENOMINATOR_MUST_BE_INTEGER.format("Numerator").getMessage());
    assertWithMessage("The error file flags a aggregate count value error").that(errorContent).contains(ErrorCode.NUMERATOR_DENOMINATOR_INVALID_VALUE.format("Denominator").getMessage());
}
Also used : 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) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 17 with AllErrors

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

the class MeasureDataValidatorTest method multipleNegativeMeasureDataTest.

@Test
void multipleNegativeMeasureDataTest() throws Exception {
    // setup
    Path path = Paths.get("src/test/resources/negative/angerMeasureDataValidations.xml");
    // execute
    Converter converter = new Converter(new PathSource(path));
    AllErrors allErrors = new AllErrors();
    try {
        converter.transform();
    } catch (TransformException exception) {
        allErrors = exception.getDetails();
    }
    List<Detail> errors = getErrors(allErrors);
    assertWithMessage("Must contain the error").that(errors).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsAllOf(ErrorCode.AGGREGATE_COUNT_VALUE_NOT_INTEGER, ErrorCode.AGGREGATE_COUNT_VALUE_NOT_SINGULAR, ErrorCode.MEASURE_DATA_VALUE_NOT_INTEGER);
}
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) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 18 with AllErrors

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

the class QrdaServiceImplTest method errorConverter.

private Converter errorConverter() {
    Converter mockConverter = mock(Converter.class);
    AllErrors allErrors = new AllErrors();
    allErrors.addError(new Error(MOCK_ERROR_SOURCE_IDENTIFIER, null));
    ConversionReport report = mock(ConversionReport.class);
    when(report.getReportDetails()).thenReturn(allErrors);
    TransformException transformException = new TransformException("mock problem", new NullPointerException(), report);
    when(mockConverter.transform()).thenThrow(transformException);
    return mockConverter;
}
Also used : AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Converter(gov.cms.qpp.conversion.Converter) Error(gov.cms.qpp.conversion.model.error.Error) ConversionReport(gov.cms.qpp.conversion.ConversionReport)

Example 19 with AllErrors

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

the class ExceptionHandlerControllerV1Test method testQppValidationExceptionHeaderContentType.

@Test
void testQppValidationExceptionHeaderContentType() {
    QppValidationException exception = new QppValidationException("test transform exception", new NullPointerException(), report);
    ResponseEntity<AllErrors> responseEntity = objectUnderTest.handleQppValidationException(exception);
    assertThat(responseEntity.getHeaders().getContentType()).isEquivalentAccordingToCompareTo(MediaType.APPLICATION_JSON_UTF8);
}
Also used : AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) QppValidationException(gov.cms.qpp.conversion.model.error.QppValidationException) Test(org.junit.jupiter.api.Test)

Example 20 with AllErrors

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

the class ExceptionHandlerControllerV1Test method testTransformExceptionStatusCode.

@Test
void testTransformExceptionStatusCode() {
    TransformException exception = new TransformException("test transform exception", new NullPointerException(), report);
    ResponseEntity<AllErrors> responseEntity = objectUnderTest.handleTransformException(exception);
    assertWithMessage("The response entity's status code must be 422.").that(responseEntity.getStatusCode()).isEquivalentAccordingToCompareTo(HttpStatus.UNPROCESSABLE_ENTITY);
}
Also used : AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Test(org.junit.jupiter.api.Test)

Aggregations

AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)31 TransformException (gov.cms.qpp.conversion.model.error.TransformException)21 Test (org.junit.jupiter.api.Test)19 Converter (gov.cms.qpp.conversion.Converter)15 PathSource (gov.cms.qpp.conversion.PathSource)12 Detail (gov.cms.qpp.conversion.model.error.Detail)11 Path (java.nio.file.Path)8 ArrayList (java.util.ArrayList)6 Error (gov.cms.qpp.conversion.model.error.Error)4 QppValidationException (gov.cms.qpp.conversion.model.error.QppValidationException)4 LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 Context (gov.cms.qpp.conversion.Context)2 InputStreamSupplierSource (gov.cms.qpp.conversion.InputStreamSupplierSource)2 XmlException (gov.cms.qpp.conversion.xml.XmlException)2 XmlUtils (gov.cms.qpp.conversion.xml.XmlUtils)2 AcceptanceTest (gov.cms.qpp.test.annotations.AcceptanceTest)2 RestAssured.given (io.restassured.RestAssured.given)2 Response (io.restassured.response.Response)2 InputStream (java.io.InputStream)2