use of gov.cms.qpp.conversion.model.error.QppValidationException in project qpp-conversion-tool by CMSgov.
the class ValidationServiceImpl method validateQpp.
/**
* Validates that the given QPP is valid.
*
* @param conversionReport A report on the status of the conversion.
*/
@Override
public void validateQpp(final ConversionReport conversionReport) {
String validationUrl = environment.getProperty(Constants.VALIDATION_URL_ENV_VARIABLE);
if (StringUtils.isEmpty(validationUrl)) {
return;
}
conversionReport.getEncoded().stream().forEach(wrapper -> {
ResponseEntity<String> validationResponse = callValidationEndpoint(validationUrl, wrapper);
if (HttpStatus.UNPROCESSABLE_ENTITY == validationResponse.getStatusCode()) {
API_LOG.warn("Failed QPP validation");
AllErrors convertedErrors = convertQppValidationErrorsToQrda(validationResponse.getBody(), wrapper);
conversionReport.setRawValidationDetails(validationResponse.getBody());
conversionReport.setReportDetails(convertedErrors);
throw new QppValidationException("Converted QPP failed validation", null, conversionReport);
}
});
}
use of gov.cms.qpp.conversion.model.error.QppValidationException 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);
}
use of gov.cms.qpp.conversion.model.error.QppValidationException in project qpp-conversion-tool by CMSgov.
the class ExceptionHandlerControllerV1Test method testQppValidationExceptionBody.
@Test
void testQppValidationExceptionBody() {
QppValidationException exception = new QppValidationException("test transform exception", new NullPointerException(), report);
ResponseEntity<AllErrors> responseEntity = objectUnderTest.handleQppValidationException(exception);
assertThat(responseEntity.getBody()).isEqualTo(allErrors);
}
use of gov.cms.qpp.conversion.model.error.QppValidationException in project qpp-conversion-tool by CMSgov.
the class ExceptionHandlerControllerV1Test method testQppValidationExceptionStatusCode.
@Test
void testQppValidationExceptionStatusCode() {
QppValidationException exception = new QppValidationException("test transform exception", new NullPointerException(), report);
ResponseEntity<AllErrors> responseEntity = objectUnderTest.handleQppValidationException(exception);
assertWithMessage("The response entity's status code must be 422.").that(responseEntity.getStatusCode()).isEquivalentAccordingToCompareTo(HttpStatus.UNPROCESSABLE_ENTITY);
}
Aggregations