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());
}
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;
}
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;
}
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);
}
Aggregations