Task task = taskService.newTask();
taskService.saveTask(task);
// Add a comment as "kermit"
identityService.setAuthenticatedUserId("kermit");
Comment comment = taskService.addComment(task.getId(), null, "This is a comment...");
identityService.setAuthenticatedUserId(null);
HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX +
RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT_COLLECTION, task.getId()));
CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertTrue(responseNode.isArray());
assertEquals(1, responseNode.size());
ObjectNode commentNode = (ObjectNode) responseNode.get(0);
assertEquals("kermit", commentNode.get("author").textValue());
assertEquals("This is a comment...", commentNode.get("message").textValue());
assertEquals(comment.getId(), commentNode.get("id").textValue());
assertTrue(commentNode.get("taskUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, task.getId(), comment.getId())));
assertEquals(task.getId(), commentNode.get("taskId").asText());
assertTrue(commentNode.get("processInstanceUrl").isNull());
assertTrue(commentNode.get("processInstanceId").isNull());
// Test with unexisting task