use of org.camunda.bpm.engine.task.Comment in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method testCleanupHistoryCaseInstanceTaskComment.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceTaskComment() {
// given
// create case instance
String caseInstanceId = caseService.createCaseInstanceByKey("oneTaskCase").getId();
Task task = taskService.createTaskQuery().singleResult();
taskService.createComment(task.getId(), null, "This is a comment...");
// assume
List<Comment> comments = taskService.getTaskComments(task.getId());
assertEquals(1, comments.size());
terminateAndCloseCaseInstance(caseInstanceId, null);
// when
historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstanceId));
// then
comments = taskService.getTaskComments(task.getId());
assertEquals(0, comments.size());
}
use of org.camunda.bpm.engine.task.Comment in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testTaskComments.
@Test
public void testTaskComments() {
int historyLevel = processEngineConfiguration.getHistoryLevel().getId();
if (historyLevel > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
Task task = taskService.newTask();
task.setOwner("johndoe");
taskService.saveTask(task);
String taskId = task.getId();
identityService.setAuthenticatedUserId("johndoe");
// Fetch the task again and update
Comment comment = taskService.createComment(taskId, null, "look at this \n isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg kajsh dfuieqpgkja rzvkfnjviuqerhogiuvysbegkjz lkhf ais liasduh flaisduh ajiasudh vaisudhv nsfd");
assertNotNull(comment.getId());
assertEquals("johndoe", comment.getUserId());
assertEquals(taskId, comment.getTaskId());
assertNull(comment.getProcessInstanceId());
assertEquals("look at this isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg ...", ((Event) comment).getMessage());
assertEquals("look at this \n isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg kajsh dfuieqpgkja rzvkfnjviuqerhogiuvysbegkjz lkhf ais liasduh flaisduh ajiasudh vaisudhv nsfd", comment.getFullMessage());
assertNotNull(comment.getTime());
taskService.createComment(taskId, "pid", "one");
taskService.createComment(taskId, "pid", "two");
Set<String> expectedComments = new HashSet<String>();
expectedComments.add("one");
expectedComments.add("two");
Set<String> comments = new HashSet<String>();
for (Comment cmt : taskService.getProcessInstanceComments("pid")) {
comments.add(cmt.getFullMessage());
}
assertEquals(expectedComments, comments);
// Finally, delete task
taskService.deleteTask(taskId, true);
}
}
use of org.camunda.bpm.engine.task.Comment in project camunda-bpm-platform by camunda.
the class TaskRestServiceInteractionTest method verifyTaskComments.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void verifyTaskComments(List<Comment> mockTaskComments, Response response) {
List list = response.as(List.class);
assertEquals(1, list.size());
LinkedHashMap<String, String> resourceHashMap = (LinkedHashMap<String, String>) list.get(0);
String returnedId = resourceHashMap.get("id");
String returnedUserId = resourceHashMap.get("userId");
String returnedTaskId = resourceHashMap.get("taskId");
Date returnedTime = DateTimeUtil.parseDate(resourceHashMap.get("time"));
String returnedFullMessage = resourceHashMap.get("message");
Comment mockComment = mockTaskComments.get(0);
assertEquals(mockComment.getId(), returnedId);
assertEquals(mockComment.getTaskId(), returnedTaskId);
assertEquals(mockComment.getUserId(), returnedUserId);
assertEquals(mockComment.getTime(), returnedTime);
assertEquals(mockComment.getFullMessage(), returnedFullMessage);
}
Aggregations