@Test public void givenDeleteOKThenOK() throws Exception { ItemStatus result = new ItemStatus(); result.setGlobalState(ProcessState.COMPLETED); result.increment(StatusCode.FATAL); result.setItemId("Itzm"); RequestResponseOK<ItemStatus> responseOK = new RequestResponseOK<ItemStatus>().addResult(result); responseOK.setHttpCode(Status.ACCEPTED.getStatusCode()); when(mock.delete()) .thenReturn(Response.status(Status.ACCEPTED).entity(responseOK).build()); RequestResponse<ItemStatus> response = client.cancelOperationProcessExecution(ID); assertEquals(response.isOk(), true); RequestResponseOK<ItemStatus> respOK = (RequestResponseOK<ItemStatus>) response; assertEquals(respOK.getResults().iterator().hasNext(), true); assertEquals(respOK.getResults().iterator().next().getGlobalStatus(), StatusCode.FATAL); assertEquals(respOK.getResults().iterator().next().getGlobalState(), ProcessState.COMPLETED); }
@Override public RequestResponse<ItemStatus> cancelOperationProcessExecution(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); Response response = null; try { response = make(delete() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() ); check(response); return RequestResponse.parseFromResponse(response, ItemStatus.class); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientServerException | IngestInternalClientNotFoundException | IngestInternalClientConflictException e) { throw new VitamClientInternalException(e); } finally { if (response != null) { response.close(); } } }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public RequestResponse<ItemStatus> cancelOperationProcessExecution(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); Response response = null; try { response = make(delete() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() ); check(response); return RequestResponse.parseFromResponse(response, ItemStatus.class); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientServerException | IngestInternalClientNotFoundException | IngestInternalClientConflictException e) { throw new VitamClientInternalException(e); } finally { if (response != null) { response.close(); } } } }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public RequestResponse<ItemStatus> cancelOperationProcessExecution(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); Response response = null; try { response = make(delete() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() ); check(response); return RequestResponse.parseFromResponse(response, ItemStatus.class); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientServerException | IngestInternalClientNotFoundException | IngestInternalClientConflictException e) { throw new VitamClientInternalException(e); } finally { if (response != null) { response.close(); } } } IngestInternalClientRest(IngestInternalClientFactory factory); }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public RequestResponse<ItemStatus> cancelOperationProcessExecution(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); Response response = null; try { response = make(delete() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() ); check(response); return RequestResponse.parseFromResponse(response, ItemStatus.class); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientServerException | IngestInternalClientNotFoundException | IngestInternalClientConflictException e) { throw new VitamClientInternalException(e); } finally { if (response != null) { 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 RequestResponse<ItemStatus> cancelOperationProcessExecution(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); Response response = null; try { response = make(delete() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() ); check(response); return RequestResponse.parseFromResponse(response, ItemStatus.class); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientServerException | IngestInternalClientNotFoundException | IngestInternalClientConflictException e) { throw new VitamClientInternalException(e); } finally { if (response != null) { 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);  }