Search in sources :

Example 16 with Metadata

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

Example 17 with Metadata

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);
}
Also used : Metadata(gov.cms.qpp.conversion.api.model.Metadata) UncheckedInterruptedException(gov.cms.qpp.conversion.api.exceptions.UncheckedInterruptedException) Waiter(net.jodah.concurrentunit.Waiter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 18 with Metadata

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

Example 19 with 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);
}
Also used : Metadata(gov.cms.qpp.conversion.api.model.Metadata) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 20 with Metadata

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

Aggregations

Metadata (gov.cms.qpp.conversion.api.model.Metadata)40 Test (org.junit.jupiter.api.Test)24 Node (gov.cms.qpp.conversion.model.Node)16 Source (gov.cms.qpp.conversion.Source)5 ConversionReport (gov.cms.qpp.conversion.ConversionReport)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 ResponseEntity (org.springframework.http.ResponseEntity)3 InvalidFileTypeException (gov.cms.qpp.conversion.api.exceptions.InvalidFileTypeException)2 NoFileInDatabaseException (gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException)2 Outcome (gov.cms.qpp.conversion.api.helper.MetadataHelper.Outcome)2 AcceptanceTest (gov.cms.qpp.test.annotations.AcceptanceTest)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 InputStreamSupplierSource (gov.cms.qpp.conversion.InputStreamSupplierSource)1 AuditException (gov.cms.qpp.conversion.api.exceptions.AuditException)1 InvalidPurposeException (gov.cms.qpp.conversion.api.exceptions.InvalidPurposeException)1 UncheckedInterruptedException (gov.cms.qpp.conversion.api.exceptions.UncheckedInterruptedException)1 MetadataHelper (gov.cms.qpp.conversion.api.helper.MetadataHelper)1 Constants (gov.cms.qpp.conversion.api.model.Constants)1 UnprocessedCpcFileData (gov.cms.qpp.conversion.api.model.UnprocessedCpcFileData)1 InputStream (java.io.InputStream)1