use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.
the class DbServiceImpl method write.
/**
* Writes the passed in {@link Metadata} to DynamoDB.
*
* If the KMS_KEY environment variable is unspecified, nothing is written. The {@link CompletableFuture} will hold an empty
* {@link Metadata} in this case.
*
* @param meta The metadata to write.
* @return A {@link CompletableFuture} that will hold the written Metadata.
*/
@Override
public CompletableFuture<Metadata> write(Metadata meta) {
String noAudit = environment.getProperty(Constants.NO_AUDIT_ENV_VARIABLE);
if (!StringUtils.isEmpty(noAudit)) {
API_LOG.warn("Not writing metadata information");
return CompletableFuture.completedFuture(new Metadata());
}
API_LOG.info("Writing item to DynamoDB");
return actOnItem(meta);
}
use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.
the class AuditServiceImplTest method testFileUploadFailureException.
@Test
public void testFileUploadFailureException() throws TimeoutException {
when(environment.getProperty(Constants.NO_AUDIT_ENV_VARIABLE)).thenReturn(null);
successfulEncodingPrep();
problematic();
final Waiter waiter = new Waiter();
CompletableFuture<Metadata> future = underTest.success(report);
future.whenComplete((nada, ex) -> {
waiter.assertNull(metadata.getQppLocator());
waiter.assertNull(metadata.getSubmissionLocator());
waiter.assertTrue(ex.getCause() instanceof UncheckedInterruptedException);
waiter.resume();
});
waiter.await(5000);
}
use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.
the class AuditServiceImplTest method before.
@Before
public void before() {
metadata = new Metadata();
mockStatic(MetadataHelper.class);
when(MetadataHelper.generateMetadata(any(Node.class), any(MetadataHelper.Outcome.class))).thenReturn(metadata);
doReturn(CompletableFuture.completedFuture(metadata)).when(dbService).write(metadata);
}
use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.
the class CpcFileServiceImplTest method testProcessFileByIdSuccess.
@Test
void testProcessFileByIdSuccess() {
Metadata returnedData = buildFakeMetadata(true, false);
when(dbService.getMetadataById(anyString())).thenReturn(returnedData);
when(dbService.write(any(Metadata.class))).thenReturn(CompletableFuture.completedFuture(returnedData));
String message = objectUnderTest.processFileById(MEEP);
verify(dbService, times(1)).getMetadataById(MEEP);
verify(dbService, times(1)).write(returnedData);
assertThat(message).isEqualTo(CpcFileServiceImpl.FILE_FOUND_PROCESSED);
}
use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.
the class CpcFileServiceImplTest method buildFakeMetadata.
Metadata buildFakeMetadata(boolean isCpc, boolean isCpcProcessed) {
Metadata metadata = new Metadata();
metadata.setCpc(isCpc ? "CPC_26" : null);
metadata.setCpcProcessed(isCpcProcessed);
metadata.setSubmissionLocator("test");
return metadata;
}
Aggregations