Search in sources :

Example 6 with Comment

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

Example 7 with Comment

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

Example 8 with Comment

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);
}
Also used : Comment(org.camunda.bpm.engine.task.Comment) ArrayList(java.util.ArrayList) List(java.util.List) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap)

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