use of org.camunda.bpm.engine.task.Comment in project camunda-bpm-platform by camunda.
the class MockProvider method createMockTaskComment.
// task comment
public static Comment createMockTaskComment() {
Comment mockComment = mock(Comment.class);
when(mockComment.getId()).thenReturn(EXAMPLE_TASK_COMMENT_ID);
when(mockComment.getTaskId()).thenReturn(EXAMPLE_TASK_ID);
when(mockComment.getUserId()).thenReturn(EXAMPLE_USER_ID);
when(mockComment.getTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_TASK_COMMENT_TIME));
when(mockComment.getFullMessage()).thenReturn(EXAMPLE_TASK_COMMENT_FULL_MESSAGE);
return mockComment;
}
use of org.camunda.bpm.engine.task.Comment in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetTaskCommentByTaskIdAndCommentId.
@Test
public void testGetTaskCommentByTaskIdAndCommentId() {
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
// create and save new task
Task task = taskService.newTask();
taskService.saveTask(task);
String taskId = task.getId();
// add comment to task
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");
// select task comment for task id and comment id
comment = taskService.getTaskComment(taskId, comment.getId());
// check returned comment
assertNotNull(comment.getId());
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());
// delete task
taskService.deleteTask(task.getId(), true);
}
}
use of org.camunda.bpm.engine.task.Comment in project camunda-bpm-platform by camunda.
the class TaskCommentResourceImpl method getComment.
public CommentDto getComment(String commentId) {
ensureHistoryEnabled(Status.NOT_FOUND);
Comment comment = engine.getTaskService().getTaskComment(taskId, commentId);
if (comment == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Task comment with id " + commentId + " does not exist for task id '" + taskId + "'.");
}
return CommentDto.fromComment(comment);
}
use of org.camunda.bpm.engine.task.Comment in project camunda-bpm-platform by camunda.
the class TaskCommentResourceImpl method createComment.
public CommentDto createComment(UriInfo uriInfo, CommentDto commentDto) {
ensureHistoryEnabled(Status.FORBIDDEN);
ensureTaskExists(Status.BAD_REQUEST);
Comment comment;
try {
comment = engine.getTaskService().createComment(taskId, null, commentDto.getMessage());
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, "Not enough parameters submitted");
}
URI uri = uriInfo.getBaseUriBuilder().path(rootResourcePath).path(TaskRestService.PATH).path(taskId + "/comment/" + comment.getId()).build();
CommentDto resultDto = CommentDto.fromComment(comment);
// GET /
resultDto.addReflexiveLink(uri, HttpMethod.GET, "self");
return resultDto;
}
use of org.camunda.bpm.engine.task.Comment in project camunda-bpm-platform by camunda.
the class TaskCommentResourceImpl method getComments.
public List<CommentDto> getComments() {
if (!isHistoryEnabled()) {
return Collections.emptyList();
}
ensureTaskExists(Status.NOT_FOUND);
List<Comment> taskComments = engine.getTaskService().getTaskComments(taskId);
List<CommentDto> comments = new ArrayList<CommentDto>();
for (Comment comment : taskComments) {
comments.add(CommentDto.fromComment(comment));
}
return comments;
}
Aggregations