use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.
the class CpcApiAcceptance method testMarkFileProcessedNotCPC.
@AcceptanceTest
void testMarkFileProcessedNotCPC() {
Metadata metadata = createDatedCpcMetadata("2018-01-02T05:00:00.000Z");
metadata.setCpc(null);
mapper.save(metadata);
String responseBody = markFileAsProcessed(metadata.getUuid(), 404);
assertThat(responseBody).isEqualTo("The file was not a CPC+ file.");
}
use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.
the class CpcApiAcceptance method testUnprocessedFilesDates.
@AcceptanceTest
void testUnprocessedFilesDates() {
Metadata afterJanuarySecondMetadata = createDatedCpcMetadata("2018-01-02T05:00:00.000Z");
Metadata beforeJanuarySecondMetadata = createDatedCpcMetadata(DbServiceImpl.START_OF_UNALLOWED_CONVERSION_TIME);
Metadata anotherAllowedMetadata = createDatedCpcMetadata("2018-02-26T14:36:43.723Z");
Metadata anotherUnallowedMetadata = createDatedCpcMetadata("2017-12-25T00:00:00.000Z");
mapper.batchSave(afterJanuarySecondMetadata, beforeJanuarySecondMetadata, anotherAllowedMetadata, anotherUnallowedMetadata);
List<Map> responseBody = getUnprocessedFiles();
responseBody.stream().forEach(map -> assertThat(Instant.parse((String) map.get("conversionDate"))).isGreaterThan(Instant.parse(DbServiceImpl.START_OF_UNALLOWED_CONVERSION_TIME)));
}
use of gov.cms.qpp.conversion.api.model.Metadata 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.api.model.Metadata in project qpp-conversion-tool by CMSgov.
the class CpcFileServiceImpl method unprocessFileById.
/**
* Process to ensure the file is a processed cpc+ file and marks the file as unprocessed
*
* @param fileId Identifier of the CPC+ file
* @return Success or failure message.
*/
@Override
public String unprocessFileById(String fileId) {
Metadata metadata = dbService.getMetadataById(fileId);
if (metadata == null) {
throw new NoFileInDatabaseException(FILE_NOT_FOUND);
} else if (metadata.getCpc() == null) {
throw new InvalidFileTypeException(INVALID_FILE);
} else if (!metadata.getCpcProcessed()) {
return FILE_FOUND_UNPROCESSED;
} else {
metadata.setCpcProcessed(false);
CompletableFuture<Metadata> metadataFuture = dbService.write(metadata);
metadataFuture.join();
return FILE_FOUND_UNPROCESSED;
}
}
use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.
the class CpcFileServiceImpl method processFileById.
/**
* Process to ensure the file is an unprocessed cpc+ file and marks the file as processed
*
* @param fileId Identifier of the CPC+ file
* @return Success or failure message.
*/
@Override
public String processFileById(String fileId) {
Metadata metadata = dbService.getMetadataById(fileId);
if (metadata == null) {
throw new NoFileInDatabaseException(FILE_NOT_FOUND);
} else if (metadata.getCpc() == null) {
throw new InvalidFileTypeException(INVALID_FILE);
} else if (metadata.getCpcProcessed()) {
return FILE_FOUND_PROCESSED;
} else {
metadata.setCpcProcessed(true);
CompletableFuture<Metadata> metadataFuture = dbService.write(metadata);
metadataFuture.join();
return FILE_FOUND_PROCESSED;
}
}
Aggregations