use of gov.cms.qpp.conversion.Source in project qpp-conversion-tool by CMSgov.
the class AuditServiceImpl method failConversion.
/**
* Audit a failed QPP conversion.
*
* @param conversionReport report of the conversion
* @return future
*/
@Override
public CompletableFuture<Void> failConversion(ConversionReport conversionReport) {
if (noAudit()) {
return null;
}
API_LOG.info("Writing audit information for a conversion failure scenario");
Metadata metadata = initMetadata(conversionReport, Outcome.CONVERSION_ERROR);
Source qrdaSource = conversionReport.getQrdaSource();
Source validationErrorSource = conversionReport.getValidationErrorsSource();
CompletableFuture<Void> allWrites = CompletableFuture.allOf(storeContent(validationErrorSource).thenAccept(metadata::setConversionErrorLocator), storeContent(qrdaSource).thenAccept(metadata::setSubmissionLocator));
return allWrites.whenComplete((ignore, thrown) -> persist(metadata, thrown));
}
use of gov.cms.qpp.conversion.Source in project qpp-conversion-tool by CMSgov.
the class QrdaControllerV1Test method uploadTestQrdaFile.
@Test
void uploadTestQrdaFile() {
ArgumentCaptor<Source> peopleCaptor = ArgumentCaptor.forClass(Source.class);
when(qrdaService.convertQrda3ToQpp(peopleCaptor.capture())).thenReturn(report);
when(auditService.success(any(ConversionReport.class))).then(invocation -> null);
when(report.getPurpose()).thenReturn("Test");
ResponseEntity qppResponse = objectUnderTest.uploadQrdaFile(multipartFile, "Test");
assertThat(peopleCaptor.getValue().getPurpose()).isEqualTo("Test");
}
use of gov.cms.qpp.conversion.Source in project qpp-conversion-tool by CMSgov.
the class AuditServiceImpl method failValidation.
/**
* Audit a failed submission validation.
*
* @param conversionReport report of the conversion
* @return future
*/
@Override
public CompletableFuture<Void> failValidation(ConversionReport conversionReport) {
if (noAudit()) {
return null;
}
API_LOG.info("Writing audit information for a validation failure scenario");
Source qrdaSource = conversionReport.getQrdaSource();
Source qppSource = conversionReport.getQppSource();
Source validationErrorSource = conversionReport.getValidationErrorsSource();
Source rawValidationErrorSource = conversionReport.getRawValidationErrorsOrEmptySource();
Metadata metadata = initMetadata(conversionReport, Outcome.VALIDATION_ERROR);
CompletableFuture<Void> allWrites = CompletableFuture.allOf(storeContent(rawValidationErrorSource).thenAccept(metadata::setRawValidationErrorLocator), storeContent(validationErrorSource).thenAccept(metadata::setValidationErrorLocator), storeContent(qppSource).thenAccept(metadata::setQppLocator), storeContent(qrdaSource).thenAccept(metadata::setSubmissionLocator));
return allWrites.whenComplete((nada, thrown) -> persist(metadata, thrown));
}
use of gov.cms.qpp.conversion.Source in project qpp-conversion-tool by CMSgov.
the class AuditServiceImpl method success.
/**
* Audit a successful conversion.
*
* @param conversionReport report of the conversion
* @return future
*/
@Override
public CompletableFuture<Metadata> success(ConversionReport conversionReport) {
if (noAudit()) {
return null;
}
API_LOG.info("Writing success audit information");
Metadata metadata = initMetadata(conversionReport, Outcome.SUCCESS);
Source qrdaSource = conversionReport.getQrdaSource();
Source qppSource = conversionReport.getQppSource();
CompletableFuture<Void> allWrites = CompletableFuture.allOf(storeContent(qrdaSource).thenAccept(metadata::setSubmissionLocator), storeContent(qppSource).thenAccept(metadata::setQppLocator));
return allWrites.whenComplete((nada, thrown) -> persist(metadata, thrown)).thenApply(ignore -> metadata);
}
Aggregations