Search in sources :

Example 11 with FileInputDetails

use of uk.gov.justice.services.adapter.rest.multipart.FileInputDetails in project microservice_framework by CJSCommonPlatform.

the class SingleFileInputDetailsServiceTest method shouldStoreTheFileInputStream.

@Test
public void shouldStoreTheFileInputStream() throws Exception {
    final UUID fileId = randomUUID();
    final FileInputDetails fileInputDetails = mock(FileInputDetails.class);
    final InputStream inputStream = mock(InputStream.class);
    final JsonObject metadata = mock(JsonObject.class);
    when(fileInputDetails.getInputStream()).thenReturn(inputStream);
    when(fileStorer.store(metadata, inputStream)).thenReturn(fileId);
    assertThat(singleFileInputDetailsService.store(fileInputDetails, metadata), is(fileId));
    verify(inputStream).close();
}
Also used : FileInputDetails(uk.gov.justice.services.adapter.rest.multipart.FileInputDetails) InputStream(java.io.InputStream) JsonObject(javax.json.JsonObject) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) Test(org.junit.Test)

Aggregations

FileInputDetails (uk.gov.justice.services.adapter.rest.multipart.FileInputDetails)11 Test (org.junit.Test)9 UUID (java.util.UUID)6 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)6 UUID.randomUUID (java.util.UUID.randomUUID)5 JsonObject (javax.json.JsonObject)5 InterceptorContext (uk.gov.justice.services.core.interceptor.InterceptorContext)5 InputStream (java.io.InputStream)3 List (java.util.List)3 Response (javax.ws.rs.core.Response)2 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Optional (java.util.Optional)1 Optional.empty (java.util.Optional.empty)1 Function (java.util.function.Function)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1 HttpHeaders (javax.ws.rs.core.HttpHeaders)1