Search in sources :

Example 1 with Comment

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;
}
Also used : Comment(org.camunda.bpm.engine.task.Comment)

Example 2 with Comment

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);
    }
}
Also used : Comment(org.camunda.bpm.engine.task.Comment) Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test)

Example 3 with Comment

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);
}
Also used : Comment(org.camunda.bpm.engine.task.Comment) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 4 with 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;
}
Also used : Comment(org.camunda.bpm.engine.task.Comment) CommentDto(org.camunda.bpm.engine.rest.dto.task.CommentDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) URI(java.net.URI) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 5 with Comment

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;
}
Also used : Comment(org.camunda.bpm.engine.task.Comment) ArrayList(java.util.ArrayList) CommentDto(org.camunda.bpm.engine.rest.dto.task.CommentDto)

Aggregations

Comment (org.camunda.bpm.engine.task.Comment)8 Task (org.camunda.bpm.engine.task.Task)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 CommentDto (org.camunda.bpm.engine.rest.dto.task.CommentDto)2 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)2 URI (java.net.URI)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)1 Deployment (org.camunda.bpm.engine.test.Deployment)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.anyString (org.mockito.Matchers.anyString)1