use of uk.gov.justice.services.fileservice.api.FileServiceException in project microservice_framework by CJSCommonPlatform.
the class SingleFileInputDetailsServiceTest method shouldThrowAFileStoreFailedExceptionIfStoringTheInputStreamFails.
@Test
public void shouldThrowAFileStoreFailedExceptionIfStoringTheInputStreamFails() throws Exception {
final FileServiceException fileServiceException = new FileServiceException("Ooops");
final FileInputDetails fileInputDetails = mock(FileInputDetails.class);
final JsonObject metadata = mock(JsonObject.class);
final InputStream inputStream = mock(InputStream.class);
when(fileInputDetails.getInputStream()).thenReturn(inputStream);
when(fileStorer.store(metadata, inputStream)).thenThrow(fileServiceException);
try {
singleFileInputDetailsService.store(fileInputDetails, metadata);
fail();
} catch (final FileStoreFailedException expected) {
assertThat(expected.getCause(), is(fileServiceException));
assertThat(expected.getMessage(), is("Failed to store file in FileStore"));
}
verify(inputStream).close();
}
use of uk.gov.justice.services.fileservice.api.FileServiceException in project microservice_framework by CJSCommonPlatform.
the class FileStreamReturningResponseStrategyTest method shouldThrowExceptionIfFileServiceThrowsException.
@Test(expected = InternalServerErrorException.class)
public void shouldThrowExceptionIfFileServiceThrowsException() throws FileServiceException {
final UUID fileId = randomUUID();
when(fileRetriever.retrieve(fileId)).thenThrow(new FileServiceException(""));
strategy.responseFor("someAction", Optional.of(envelope().with(metadataWithDefaults()).withPayloadOf(fileId, "fileId").build()));
}
Aggregations