Search in sources :

Example 1 with Source

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));
}
Also used : Metadata(gov.cms.qpp.conversion.api.model.Metadata) Source(gov.cms.qpp.conversion.Source)

Example 2 with Source

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");
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ConversionReport(gov.cms.qpp.conversion.ConversionReport) Source(gov.cms.qpp.conversion.Source) Test(org.junit.jupiter.api.Test)

Example 3 with Source

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));
}
Also used : Metadata(gov.cms.qpp.conversion.api.model.Metadata) Source(gov.cms.qpp.conversion.Source)

Example 4 with Source

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);
}
Also used : ConversionReport(gov.cms.qpp.conversion.ConversionReport) Logger(org.slf4j.Logger) AuditException(gov.cms.qpp.conversion.api.exceptions.AuditException) Metadata(gov.cms.qpp.conversion.api.model.Metadata) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) UUID(java.util.UUID) Outcome(gov.cms.qpp.conversion.api.helper.MetadataHelper.Outcome) MetadataHelper(gov.cms.qpp.conversion.api.helper.MetadataHelper) Environment(org.springframework.core.env.Environment) Service(org.springframework.stereotype.Service) Source(gov.cms.qpp.conversion.Source) Constants(gov.cms.qpp.conversion.api.model.Constants) InputStream(java.io.InputStream) Metadata(gov.cms.qpp.conversion.api.model.Metadata) Source(gov.cms.qpp.conversion.Source)

Aggregations

Source (gov.cms.qpp.conversion.Source)4 Metadata (gov.cms.qpp.conversion.api.model.Metadata)3 ConversionReport (gov.cms.qpp.conversion.ConversionReport)2 AuditException (gov.cms.qpp.conversion.api.exceptions.AuditException)1 MetadataHelper (gov.cms.qpp.conversion.api.helper.MetadataHelper)1 Outcome (gov.cms.qpp.conversion.api.helper.MetadataHelper.Outcome)1 Constants (gov.cms.qpp.conversion.api.model.Constants)1 InputStream (java.io.InputStream)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Test (org.junit.jupiter.api.Test)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Environment (org.springframework.core.env.Environment)1 ResponseEntity (org.springframework.http.ResponseEntity)1 Service (org.springframework.stereotype.Service)1