Search in sources :

Example 1 with Error

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

the class ConversionReportTest method getErrorStream.

@Test
void getErrorStream() {
    Converter converter = new Converter(new PathSource(Paths.get("../qrda-files/valid-QRDA-III-latest.xml")));
    ConversionReport badReport = converter.getReport();
    Error error = new Error();
    error.setMessage("meep");
    AllErrors errors = new AllErrors();
    errors.addError(error);
    badReport.setReportDetails(errors);
    AllErrors echo = JsonHelper.readJson(badReport.getValidationErrorsSource().toInputStream(), AllErrors.class);
    assertThat(echo.toString()).isEqualTo(errors.toString());
}
Also used : AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) Error(gov.cms.qpp.conversion.model.error.Error) Test(org.junit.jupiter.api.Test)

Example 2 with Error

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

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

the class ValidationServiceImpl method convertQppValidationErrorsToQrda.

/**
 * Converts the QPP error returned from the validation API to QRDA3 errors
 *
 * @param validationResponse The JSON response containing a QPP error.
 * @param wrapper The QPP that resulted in the QPP error.
 * @return The QRDA3 errors.
 */
AllErrors convertQppValidationErrorsToQrda(String validationResponse, JsonWrapper wrapper) {
    AllErrors errors = new AllErrors();
    if (validationResponse == null) {
        return errors;
    }
    Error error = getError(validationResponse);
    error.getDetails().forEach(detail -> {
        detail.setMessage(SV_LABEL + detail.getMessage());
        String newPath = UNABLE_PROVIDE_XPATH;
        try {
            newPath = PathCorrelator.prepPath(detail.getPath(), wrapper);
        } catch (ClassCastException | JsonPathException exc) {
            API_LOG.warn("Failed to convert from json path to an XPath.", exc);
        }
        detail.setPath(newPath);
    });
    errors.addError(error);
    return errors;
}
Also used : AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) Error(gov.cms.qpp.conversion.model.error.Error) JsonPathException(com.jayway.jsonpath.JsonPathException)

Example 4 with Error

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

the class ConverterTest method checkup.

private void checkup(TransformException exception, LocalizedError error) {
    AllErrors allErrors = exception.getDetails();
    List<Error> errors = allErrors.getErrors();
    assertWithMessage("There must only be one error source.").that(errors).hasSize(1);
    List<Detail> details = errors.get(0).getDetails();
    assertWithMessage("There must be only one validation error.").that(details).hasSize(1);
    assertWithMessage("The validation error was incorrect").that(details).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsExactly(error);
}
Also used : AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) Error(gov.cms.qpp.conversion.model.error.Error) LocalizedError(gov.cms.qpp.conversion.model.error.LocalizedError) Detail(gov.cms.qpp.conversion.model.error.Detail)

Aggregations

AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)4 Error (gov.cms.qpp.conversion.model.error.Error)4 JsonPathException (com.jayway.jsonpath.JsonPathException)1 ConversionReport (gov.cms.qpp.conversion.ConversionReport)1 Converter (gov.cms.qpp.conversion.Converter)1 Detail (gov.cms.qpp.conversion.model.error.Detail)1 LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)1 TransformException (gov.cms.qpp.conversion.model.error.TransformException)1 Test (org.junit.jupiter.api.Test)1