@ApiOperation(value = "Post action request to delete a bulk of historic process instances", tags = {
            "Manage History Process Instances" }, nickname = "bulkDeleteHistoricProcessInstances", code = 204)
    @ApiResponses(value = {
            @ApiResponse(code = 204, message = "Indicates the bulk of historic process instances was found and deleted. Response body is left empty intentionally."),
            @ApiResponse(code = 404, message = "Indicates at least one requested process instance was not found.")
    })
    @PostMapping(value = "/history/historic-process-instances/delete")
    @ResponseStatus(value = HttpStatus.NO_CONTENT)
    public void bulkDeleteHistoricProcessInstances(@ApiParam(name = "bulkDeleteRestActionRequest")
    @RequestBody BulkDeleteInstancesRestActionRequest request) {
        if (BulkDeleteInstancesRestActionRequest.DELETE_ACTION.equals(request.getAction())) {
            if (restApiInterceptor != null) {
                restApiInterceptor.bulkDeleteHistoricProcessInstances(request.getInstanceIds());
            }
            historyService.bulkDeleteHistoricProcessInstances(request.getInstanceIds());
        } else {
            throw new FlowableIllegalArgumentException("Illegal action: '" + request.getAction() + "'.");
        }
    }
@Test
    @Deployment(resources = { "org/flowable/rest/service/api/oneTaskProcess.bpmn20.xml" })
    public void testBulkDeleteHistoricProcessInstances() throws Exception {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
        ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess");
        ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess");

        Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
        taskService.complete(task.getId());

        task = taskService.createTaskQuery().processInstanceId(processInstance2.getId()).singleResult();
        taskService.complete(task.getId());

        task = taskService.createTaskQuery().processInstanceId(processInstance3.getId()).singleResult();
        taskService.complete(task.getId());

        assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(1);
        assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance2.getId()).count()).isEqualTo(1);
        assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance3.getId()).count()).isEqualTo(1);

        String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCES) + "/delete";

        ObjectNode body = objectMapper.createObjectNode();
        body.put("action", "delete");
        body.putArray("instanceIds").add(processInstance.getId()).add(processInstance2.getId());
        HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + url);
        httpPost.setEntity(new StringEntity(body.toString()));
        closeResponse(executeRequest(httpPost, HttpStatus.SC_NO_CONTENT));

        assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
        assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance2.getId()).count()).isZero();
        assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance3.getId()).count()).isEqualTo(1);

    }