Search in sources :

Example 21 with Metadata

use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.

the class CpcFileServiceImplTest method testUnprocessFileByIdSuccess.

@Test
void testUnprocessFileByIdSuccess() {
    Metadata returnedData = buildFakeMetadata(true, true);
    when(dbService.getMetadataById(anyString())).thenReturn(returnedData);
    when(dbService.write(any(Metadata.class))).thenReturn(CompletableFuture.completedFuture(returnedData));
    String message = objectUnderTest.unprocessFileById(MEEP);
    verify(dbService, times(1)).getMetadataById(MEEP);
    verify(dbService, times(1)).write(returnedData);
    assertThat(message).isEqualTo(CpcFileServiceImpl.FILE_FOUND_UNPROCESSED);
}
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 22 with Metadata

use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.

the class DbServiceImplTest method testNoWriteBecauseNoAudit.

@Test
void testNoWriteBecauseNoAudit() {
    when(environment.getProperty(Constants.NO_AUDIT_ENV_VARIABLE)).thenReturn("trueOrSomething");
    Metadata metadataIn = new Metadata();
    metadataIn.setTin("testTin");
    Metadata metadataOut = writeMeta(metadataIn);
    verifyZeroInteractions(dbMapper);
    assertWithMessage("The returned metadata must be an empty metadata.").that(metadataOut.getUuid()).isNull();
}
Also used : Metadata(gov.cms.qpp.conversion.api.model.Metadata) Test(org.junit.jupiter.api.Test)

Example 23 with Metadata

use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.

the class DbServiceImplTest method testWriteByEmpty.

@Test
void testWriteByEmpty() {
    when(environment.getProperty(Constants.NO_AUDIT_ENV_VARIABLE)).thenReturn("");
    Metadata meta = writeMeta();
    assertThat(meta).isNotNull();
    verify(dbMapper, times(1)).save(any(Metadata.class));
}
Also used : Metadata(gov.cms.qpp.conversion.api.model.Metadata) Test(org.junit.jupiter.api.Test)

Example 24 with Metadata

use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.

the class DbServiceImplTest method testWriteByNull.

@Test
void testWriteByNull() {
    when(environment.getProperty(Constants.NO_AUDIT_ENV_VARIABLE)).thenReturn(null);
    Metadata meta = writeMeta();
    assertThat(meta).isNotNull();
    verify(dbMapper, times(1)).save(any(Metadata.class));
}
Also used : Metadata(gov.cms.qpp.conversion.api.model.Metadata) Test(org.junit.jupiter.api.Test)

Example 25 with Metadata

use of gov.cms.qpp.conversion.api.model.Metadata in project qpp-conversion-tool by CMSgov.

the class DbServiceImplTest method testGetMetadataById.

@Test
void testGetMetadataById() {
    String fakeUuid = "1337-f4ke-uuid";
    when(dbMapper.load(eq(Metadata.class), anyString())).thenReturn(new Metadata());
    Metadata fakeMetadata = underTest.getMetadataById(fakeUuid);
    verify(dbMapper, times(1)).load(eq(Metadata.class), anyString());
    assertThat(fakeMetadata).isNotNull();
}
Also used : Metadata(gov.cms.qpp.conversion.api.model.Metadata) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

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