@Test public void givenNotFoundWhenDownloadObjectThenReturnKo() { when(mock.get()).thenReturn(Response.status(Status.NOT_FOUND.getStatusCode()).build()); ThrowingCallable throwingCallable = () -> client.downloadObjectAsync("1", IngestCollection.MANIFESTS).readEntity(InputStream.class); assertThatThrownBy(throwingCallable) .isInstanceOf(IngestInternalClientNotFoundException.class); }
@Override public Response downloadObjectAsync(String objectId, IngestCollection type) throws InvalidParseOperationException, IngestInternalClientServerException, IngestInternalClientNotFoundException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; try { response = make(get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withOctetAccept()); check(response); return response; } catch (VitamClientException | WorkspaceClientServerException | NotAcceptableClientException e) { throw new IngestInternalClientServerException(e); } catch (IngestInternalClientNotFoundException e) { throw new IngestInternalClientNotFoundException(e); } finally { if (Status.fromStatusCode(response.getStatus()).getFamily() != SUCCESSFUL) { response.close(); } } }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public Response downloadObjectAsync(String objectId, IngestCollection type) throws InvalidParseOperationException, IngestInternalClientServerException, IngestInternalClientNotFoundException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; try { response = make(get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withOctetAccept()); check(response); return response; } catch (VitamClientException | WorkspaceClientServerException | NotAcceptableClientException e) { throw new IngestInternalClientServerException(e); } catch (IngestInternalClientNotFoundException e) { throw new IngestInternalClientNotFoundException(e); } finally { if (Status.fromStatusCode(response.getStatus()).getFamily() != SUCCESSFUL) { response.close(); } } } }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public Response downloadObjectAsync(String objectId, IngestCollection type) throws InvalidParseOperationException, IngestInternalClientServerException, IngestInternalClientNotFoundException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; try { response = make(get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withOctetAccept()); check(response); return response; } catch (VitamClientException | WorkspaceClientServerException | NotAcceptableClientException e) { throw new IngestInternalClientServerException(e); } catch (IngestInternalClientNotFoundException e) { throw new IngestInternalClientNotFoundException(e); } finally { if (Status.fromStatusCode(response.getStatus()).getFamily() != SUCCESSFUL) { response.close(); } } } IngestInternalClientRest(IngestInternalClientFactory factory); }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public Response downloadObjectAsync(String objectId, IngestCollection type) throws InvalidParseOperationException, IngestInternalClientServerException, IngestInternalClientNotFoundException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; try { response = make(get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withOctetAccept()); check(response); return response; } catch (VitamClientException | WorkspaceClientServerException | NotAcceptableClientException e) { throw new IngestInternalClientServerException(e); } catch (IngestInternalClientNotFoundException e) { throw new IngestInternalClientNotFoundException(e); } finally { if (Status.fromStatusCode(response.getStatus()).getFamily() != SUCCESSFUL) { response.close(); } } } IngestInternalClientRest(IngestInternalClientFactory factory); @Override void uploadInitialLogbook(Iterable<LogbookOperationParameters> logbookParametersList); @Override void upload(InputStream inputStream, MediaType archiveMimeType, WorkFlow workflow, String actionAfterInit); @Override void initWorkflow(WorkFlow workFlow); @Override void uploadFinalLogbook(Iterable<LogbookOperationParameters> logbookParametersList); @Override Response downloadObjectAsync(String objectId, IngestCollection type); @Override void storeATR(GUID guid, InputStream input); @Override RequestResponse<ItemStatus> updateOperationActionProcess(String actionId, String operationId); @Override ItemStatus getOperationProcessStatus(String id); @Override RequestResponse<ItemStatus> getOperationProcessExecutionDetails(String id); @Override RequestResponse<ItemStatus> cancelOperationProcessExecution(String id); @Override RequestResponse<ProcessDetail> listOperationsDetails(ProcessQuery query); @Override RequestResponse<WorkFlow> getWorkflowDefinitions(); @Override Optional<WorkFlow> getWorkflowDetails(String workflowIdentifier); }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public Response downloadObjectAsync(String objectId, IngestCollection type) throws InvalidParseOperationException, IngestInternalClientServerException, IngestInternalClientNotFoundException { ParametersChecker.checkParameter(BLANK_OBJECT_ID, objectId); ParametersChecker.checkParameter(BLANK_TYPE, type); Response response = null; try { response = make(get() .withPath(INGEST_URL + "/" + objectId + "/" + type.getCollectionName()) .withOctetAccept()); check(response); return response; } catch (VitamClientException | WorkspaceClientServerException | NotAcceptableClientException e) { throw new IngestInternalClientServerException(e); } catch (IngestInternalClientNotFoundException e) { throw new IngestInternalClientNotFoundException(e); } finally { if (Status.fromStatusCode(response.getStatus()).getFamily() != SUCCESSFUL) { response.close(); } } } IngestInternalClientRest(IngestInternalClientFactory factory); @Override void uploadInitialLogbook(Iterable<LogbookOperationParameters> logbookParametersList); @Override void upload(InputStream inputStream, MediaType archiveMimeType, WorkFlow workflow, String actionAfterInit); @Override void initWorkflow(WorkFlow workFlow); @Override void uploadFinalLogbook(Iterable<LogbookOperationParameters> logbookParametersList); @Override Response downloadObjectAsync(String objectId, IngestCollection type); @Override void storeATR(GUID guid, InputStream input); @Override RequestResponse<ItemStatus> updateOperationActionProcess(String actionId, String operationId); @Override ItemStatus getOperationProcessStatus(String id); @Override RequestResponse<ItemStatus> getOperationProcessExecutionDetails(String id); @Override RequestResponse<ItemStatus> cancelOperationProcessExecution(String id); @Override RequestResponse<ProcessDetail> listOperationsDetails(ProcessQuery query); @Override RequestResponse<WorkFlow> getWorkflowDefinitions(); @Override Optional<WorkFlow> getWorkflowDetails(String workflowIdentifier);  }