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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations