@Test public void givenInputstreamWhenDownloadObjectThenReturnOK() throws VitamClientException { when(mock.get()).thenReturn(ClientMockResultHelper.getObjectStream()); try (final InputStream fakeUploadResponseInputStream = client.downloadObjectAsync(new VitamContext(TENANT_ID), "1", IngestCollection.MANIFESTS) .readEntity(InputStream.class)) { assertNotNull(fakeUploadResponseInputStream); assertTrue(IOUtils.contentEquals(fakeUploadResponseInputStream, IOUtils.toInputStream("test", CharsetUtils.UTF_8))); } catch (final IOException e) { e.printStackTrace(); fail(); } }
public Response downloadObjectAsync(VitamContext vitamContext, String objectId, IngestCollection type) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; VitamRequestBuilder request = get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withHeaders(vitamContext.getHeaders()) .withOctetAccept(); try { response = make(request); check(response); return response; } catch (IngestExternalClientServerException | IngestExternalException e) { throw new VitamClientException(e); } catch (IngestExternalClientNotFoundException e) { return response; } }
IngestExternalClientRest extends DefaultClient implements IngestExternalClient { public Response downloadObjectAsync(VitamContext vitamContext, String objectId, IngestCollection type) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; VitamRequestBuilder request = get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withHeaders(vitamContext.getHeaders()) .withOctetAccept(); try { response = make(request); check(response); return response; } catch (IngestExternalClientServerException | IngestExternalException e) { throw new VitamClientException(e); } catch (IngestExternalClientNotFoundException e) { return response; } } }
IngestExternalClientRest extends DefaultClient implements IngestExternalClient { public Response downloadObjectAsync(VitamContext vitamContext, String objectId, IngestCollection type) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; VitamRequestBuilder request = get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withHeaders(vitamContext.getHeaders()) .withOctetAccept(); try { response = make(request); check(response); return response; } catch (IngestExternalClientServerException | IngestExternalException e) { throw new VitamClientException(e); } catch (IngestExternalClientNotFoundException e) { return response; } } IngestExternalClientRest(IngestExternalClientFactory factory); }
IngestExternalClientRest extends DefaultClient implements IngestExternalClient { public Response downloadObjectAsync(VitamContext vitamContext, String objectId, IngestCollection type) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; VitamRequestBuilder request = get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withHeaders(vitamContext.getHeaders()) .withOctetAccept(); try { response = make(request); check(response); return response; } catch (IngestExternalClientServerException | IngestExternalException e) { throw new VitamClientException(e); } catch (IngestExternalClientNotFoundException e) { return response; } } IngestExternalClientRest(IngestExternalClientFactory factory); @Override RequestResponse<Void> ingest(VitamContext vitamContext, InputStream stream,
        String contextId,
        String action); @Override RequestResponse<Void> ingest(VitamContext vitamContext, InputStream stream,
        IngestRequestParameters ingestRequestParameters); Response downloadObjectAsync(VitamContext vitamContext, String objectId,
        IngestCollection type); @Override RequestResponse<Void> ingestLocal(VitamContext vitamContext, LocalFile localFile, String contextId,
        String action); @Override RequestResponse<Void> ingestLocal(VitamContext vitamContext, LocalFile localFile,
        IngestRequestParameters ingestRequestParameters); }
IngestExternalClientRest extends DefaultClient implements IngestExternalClient { public Response downloadObjectAsync(VitamContext vitamContext, String objectId, IngestCollection type) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; VitamRequestBuilder request = get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withHeaders(vitamContext.getHeaders()) .withOctetAccept(); try { response = make(request); check(response); return response; } catch (IngestExternalClientServerException | IngestExternalException e) { throw new VitamClientException(e); } catch (IngestExternalClientNotFoundException e) { return response; } } IngestExternalClientRest(IngestExternalClientFactory factory); @Override RequestResponse<Void> ingest(VitamContext vitamContext, InputStream stream,
        String contextId,
        String action); @Override RequestResponse<Void> ingest(VitamContext vitamContext, InputStream stream,
        IngestRequestParameters ingestRequestParameters); Response downloadObjectAsync(VitamContext vitamContext, String objectId,
        IngestCollection type); @Override RequestResponse<Void> ingestLocal(VitamContext vitamContext, LocalFile localFile, String contextId,
        String action); @Override RequestResponse<Void> ingestLocal(VitamContext vitamContext, LocalFile localFile,
        IngestRequestParameters ingestRequestParameters);  }