Search in sources :

Example 6 with NoFileInDatabaseException

use of gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException in project qpp-conversion-tool by CMSgov.

the class CpcFileServiceImplTest method testProcessFileByIdFileNotFound.

@Test
void testProcessFileByIdFileNotFound() {
    when(dbService.getMetadataById(anyString())).thenReturn(null);
    NoFileInDatabaseException expectedException = assertThrows(NoFileInDatabaseException.class, () -> objectUnderTest.processFileById("test"));
    verify(dbService, times(1)).getMetadataById(anyString());
    assertThat(expectedException).hasMessageThat().isEqualTo(CpcFileServiceImpl.FILE_NOT_FOUND);
}
Also used : NoFileInDatabaseException(gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with NoFileInDatabaseException

use of gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException in project qpp-conversion-tool by CMSgov.

the class CpcFileServiceImplTest method testGetFileByIdWithProcessedFile.

@Test
void testGetFileByIdWithProcessedFile() {
    when(dbService.getMetadataById(anyString())).thenReturn(buildFakeMetadata(true, true));
    when(storageService.getFileByLocationId("test")).thenReturn(new ByteArrayInputStream("1337".getBytes()));
    NoFileInDatabaseException expectedException = assertThrows(NoFileInDatabaseException.class, () -> objectUnderTest.getFileById("test"));
    verify(dbService, times(1)).getMetadataById(anyString());
    assertThat(expectedException).hasMessageThat().isEqualTo(CpcFileServiceImpl.FILE_NOT_FOUND);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) NoFileInDatabaseException(gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with NoFileInDatabaseException

use of gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException in project qpp-conversion-tool by CMSgov.

the class CpcFileServiceImplTest method testGetFileByIdWithMips.

@Test
void testGetFileByIdWithMips() {
    when(dbService.getMetadataById(anyString())).thenReturn(buildFakeMetadata(false, false));
    when(storageService.getFileByLocationId("test")).thenReturn(new ByteArrayInputStream("1337".getBytes()));
    NoFileInDatabaseException expectedException = assertThrows(NoFileInDatabaseException.class, () -> objectUnderTest.getFileById("test"));
    verify(dbService, times(1)).getMetadataById(anyString());
    assertThat(expectedException).hasMessageThat().isEqualTo(CpcFileServiceImpl.FILE_NOT_FOUND);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) NoFileInDatabaseException(gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with NoFileInDatabaseException

use of gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException in project qpp-conversion-tool by CMSgov.

the class ExceptionHandlerControllerV1Test method testFileNotFoundExceptionHeaderContentType.

@Test
void testFileNotFoundExceptionHeaderContentType() {
    NoFileInDatabaseException exception = new NoFileInDatabaseException(CpcFileServiceImpl.FILE_NOT_FOUND);
    ResponseEntity<String> responseEntity = objectUnderTest.handleFileNotFoundException(exception);
    assertThat(responseEntity.getHeaders().getContentType()).isEquivalentAccordingToCompareTo(MediaType.TEXT_PLAIN);
}
Also used : NoFileInDatabaseException(gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException) Test(org.junit.jupiter.api.Test)

Example 10 with NoFileInDatabaseException

use of gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException in project qpp-conversion-tool by CMSgov.

the class ExceptionHandlerControllerV1Test method testFileNotFoundExceptionBody.

@Test
void testFileNotFoundExceptionBody() {
    NoFileInDatabaseException exception = new NoFileInDatabaseException(CpcFileServiceImpl.FILE_NOT_FOUND);
    ResponseEntity<String> responseEntity = objectUnderTest.handleFileNotFoundException(exception);
    assertThat(responseEntity.getBody()).isEqualTo(CpcFileServiceImpl.FILE_NOT_FOUND);
}
Also used : NoFileInDatabaseException(gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException) Test(org.junit.jupiter.api.Test)

Aggregations

NoFileInDatabaseException (gov.cms.qpp.conversion.api.exceptions.NoFileInDatabaseException)10 Test (org.junit.jupiter.api.Test)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InvalidFileTypeException (gov.cms.qpp.conversion.api.exceptions.InvalidFileTypeException)2 Metadata (gov.cms.qpp.conversion.api.model.Metadata)2