@Test public void givenNotFoundWhenDownloadObjectThenReturn404() throws VitamClientException, InvalidParseOperationException, IOException { VitamError error = VitamCodeHelper.toVitamError(VitamCode.INGEST_EXTERNAL_NOT_FOUND, "NOT FOUND"); AbstractMockClient.FakeInboundResponse fakeResponse = new AbstractMockClient.FakeInboundResponse(Status.NOT_FOUND, JsonHandler.writeToInpustream(error), MediaType.APPLICATION_OCTET_STREAM_TYPE, new MultivaluedHashMap<String, Object>()); when(mock.get()).thenReturn(fakeResponse); try (InputStream input = client.downloadObjectAsync(new VitamContext(TENANT_ID), "1", IngestCollection.MANIFESTS) .readEntity(InputStream.class)) { VitamError response = JsonHandler.getFromInputStream(input, VitamError.class); assertEquals(Status.NOT_FOUND.getStatusCode(), response.getHttpCode()); } }
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);  }