use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.
the class QrdaServiceImplTest method testConvertQrda3ToQppError.
@Test
void testConvertQrda3ToQppError() {
TransformException exception = assertThrows(TransformException.class, () -> objectUnderTest.convertQrda3ToQpp(MOCK_ERROR_QRDA_SOURCE));
AllErrors allErrors = exception.getDetails();
assertThat(allErrors.getErrors().get(0).getSourceIdentifier()).isSameAs(MOCK_ERROR_SOURCE_IDENTIFIER);
}
use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.
the class ValidationServiceImplTest method testValidationFail.
@Test
void testValidationFail() throws IOException {
String validationUrl = "https://qpp.net/validate";
when(environment.getProperty(eq(Constants.VALIDATION_URL_ENV_VARIABLE))).thenReturn(validationUrl);
ResponseEntity<String> spiedResponseEntity = spy(new ResponseEntity<>(FileUtils.readFileToString(pathToSubmissionError.toFile(), "UTF-8"), HttpStatus.UNPROCESSABLE_ENTITY));
when(restTemplate.postForEntity(eq(validationUrl), any(HttpEntity.class), eq(String.class))).thenReturn(spiedResponseEntity);
TransformException thrown = assertThrows(TransformException.class, () -> objectUnderTest.validateQpp(converter.getReport()));
assertThat(thrown).hasMessageThat().isEqualTo("Converted QPP failed validation");
}
use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.
the class ClinicalDocumentValidatorTest method testClinicalDocumentValidationParsesMultipleErrors.
@Test
void testClinicalDocumentValidationParsesMultipleErrors() {
// setup
Path path = Paths.get("src/test/resources/negative/angerClinicalDocumentValidations.xml");
// execute
Context context = new Context();
context.setDoDefaults(true);
Converter converter = new Converter(new PathSource(path), context);
AllErrors allErrors = new AllErrors();
try {
converter.transform();
} catch (TransformException exception) {
allErrors = exception.getDetails();
}
List<Detail> errors = getErrors(allErrors);
assertWithMessage("Must have 4 errors").that(errors).hasSize(4);
assertWithMessage("Must contain the correct errors").that(errors).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsAllOf(ErrorCode.CLINICAL_DOCUMENT_MISSING_PROGRAM_NAME, ErrorCode.REPORTING_PARAMETERS_MUST_CONTAIN_SINGLE_PERFORMANCE_START);
}
use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.
the class ConversionFileWriterWrapper method executeConverter.
/**
* Execute the converter and do initial handling of the result.
*
* @param converter The Converter to execute.
*/
private void executeConverter(Converter converter) {
try {
JsonWrapper jsonWrapper = converter.transform();
Path outFile = getOutputFile(source.getName(), true);
DEV_LOG.info("Successful conversion. Writing out QPP to {}", outFile.toString());
writeOutQpp(jsonWrapper, outFile);
} catch (TransformException exception) {
AllErrors allErrors = exception.getDetails();
Path outFile = getOutputFile(source.getName(), false);
DEV_LOG.warn("There were errors during conversion. Writing out errors to " + outFile.toString(), exception);
writeOutErrors(allErrors, outFile);
}
}
use of gov.cms.qpp.conversion.model.error.TransformException 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;
}
Aggregations