@ApiOperation(value = "Delete a comment on a historic process instance", tags = { "History Process" }, code = 204)
    @ApiResponses(value = {
            @ApiResponse(code = 204, message = "Indicates the historic process instance and comment were found and the comment is deleted. Response body is left empty intentionally."),
            @ApiResponse(code = 404, message = "Indicates the requested historic process instance was not found or the historic process instance does not have a comment with the given ID.") })
    @DeleteMapping(value = "/history/historic-process-instances/{processInstanceId}/comments/{commentId}")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public void deleteComment(@ApiParam(name = "processInstanceId") @PathVariable("processInstanceId") String processInstanceId, @ApiParam(name = "commentId") @PathVariable("commentId") String commentId) {

        HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);

        Comment comment = taskService.getComment(commentId);
        if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) {
            throw new FlowableObjectNotFoundException("Process instance '" + instance.getId() + "' does not have a comment with id '" + commentId + "'.", Comment.class);
        }

        taskService.deleteComment(commentId);
    }
@Test
    @Deployment(resources = { "org/flowable/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
    public void testGetComments() throws Exception {
        ProcessInstance pi = null;

        try {
            pi = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            // Add a comment as "kermit"
            identityService.setAuthenticatedUserId("kermit");
            Comment comment = taskService.addComment(null, pi.getId(), "This is a comment...");
            identityService.setAuthenticatedUserId(null);

            CloseableHttpResponse response = executeRequest(
                    new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT_COLLECTION, pi.getId())),
                    HttpStatus.SC_OK);

            assertThat(response.getStatusLine().getStatusCode()).isEqualTo(HttpStatus.SC_OK);

            JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
            closeResponse(response);
            assertThat(responseNode).isNotNull();
            assertThatJson(responseNode)
                    .when(Option.IGNORING_EXTRA_FIELDS)
                    .isEqualTo(" [{"
                            + "   id: '" + comment.getId() + "',"
                            + "   author: 'kermit',"
                            + "   message: 'This is a comment...',"
                            + "   taskId: null,"
                            + "   taskUrl: null,"
                            + "   processInstanceId: '" + pi.getProcessInstanceId() + "',"
                            + "   processInstanceUrl: '" + SERVER_URL_PREFIX + RestUrls
                            .createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT, pi.getId(), comment.getId()) + "'"
                            + "}]");

            // Test with unexisting task
            closeResponse(
                    executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT_COLLECTION, "unexistingtask")),
                            HttpStatus.SC_NOT_FOUND));

        } finally {
            if (pi != null) {
                List<Comment> comments = taskService.getProcessInstanceComments(pi.getId());
                for (Comment c : comments) {
                    taskService.deleteComment(c.getId());
                }
            }
        }
    }