Search in sources :

Example 6 with Comment

use of org.kie.api.task.model.Comment in project jbpm by kiegroup.

the class UserTaskServiceImplTest method testCommentOperations.

@Test
public void testCommentOperations() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
    assertNotNull(taskIds);
    assertEquals(1, taskIds.size());
    Long taskId = taskIds.get(0);
    List<Comment> comments = userTaskService.getCommentsByTaskId(taskId);
    assertNotNull(comments);
    assertEquals(0, comments.size());
    Long commentId = userTaskService.addComment(taskId, "Simple comment", "john", new Date());
    assertNotNull(commentId);
    Long commentId2 = userTaskService.addComment(taskId, "Another comment", "john", new Date());
    assertNotNull(commentId2);
    comments = userTaskService.getCommentsByTaskId(taskId);
    assertNotNull(comments);
    assertEquals(2, comments.size());
    Comment cm = userTaskService.getCommentById(taskId, commentId2);
    assertNotNull(cm);
    assertEquals("john", cm.getAddedBy().getId());
    assertEquals("Another comment", cm.getText());
    userTaskService.deleteComment(taskId, commentId2);
    comments = userTaskService.getCommentsByTaskId(taskId);
    assertNotNull(comments);
    assertEquals(1, comments.size());
}
Also used : Comment(org.kie.api.task.model.Comment) Date(java.util.Date) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 7 with Comment

use of org.kie.api.task.model.Comment in project jbpm by kiegroup.

the class CollectionUtils method readCommentList.

public static List<Comment> readCommentList(ObjectInput in) throws IOException, ClassNotFoundException {
    int size = in.readInt();
    List<Comment> list = new ArrayList<Comment>(size);
    for (int i = 0; i < size; i++) {
        Comment item = new CommentImpl();
        item.readExternal(in);
        list.add(item);
    }
    return list;
}
Also used : Comment(org.kie.api.task.model.Comment) ArrayList(java.util.ArrayList) CommentImpl(org.jbpm.services.task.impl.model.CommentImpl)

Example 8 with Comment

use of org.kie.api.task.model.Comment in project jbpm by kiegroup.

the class UserTaskServiceEJBIntegrationTest method testCommentOperations.

@Test
public void testCommentOperations() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
    assertNotNull(taskIds);
    assertEquals(1, taskIds.size());
    Long taskId = taskIds.get(0);
    List<Comment> comments = userTaskService.getCommentsByTaskId(taskId);
    assertNotNull(comments);
    assertEquals(0, comments.size());
    Long commentId = userTaskService.addComment(taskId, "Simple comment", "john", new Date());
    assertNotNull(commentId);
    Long commentId2 = userTaskService.addComment(taskId, "Another comment", "john", new Date());
    assertNotNull(commentId2);
    comments = userTaskService.getCommentsByTaskId(taskId);
    assertNotNull(comments);
    assertEquals(2, comments.size());
    Comment cm = userTaskService.getCommentById(taskId, commentId2);
    assertNotNull(cm);
    assertEquals("john", cm.getAddedBy().getId());
    assertEquals("Another comment", cm.getText());
    userTaskService.deleteComment(taskId, commentId2);
    comments = userTaskService.getCommentsByTaskId(taskId);
    assertNotNull(comments);
    assertEquals(1, comments.size());
}
Also used : Comment(org.kie.api.task.model.Comment) Date(java.util.Date) Test(org.junit.Test)

Example 9 with Comment

use of org.kie.api.task.model.Comment in project jbpm by kiegroup.

the class ETaskCommentTest method testMultipleUserComments.

@Test
public void testMultipleUserComments() {
    ProcessInstance pi = ejb.startAndGetProcess(ProcessDefinitions.HUMAN_TASK);
    Assertions.assertThat(pi).isNotNull();
    Assertions.assertThat(pi.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    List<TaskSummary> taskSummaryList = ejb.getTasksAssignedAsPotentialOwner(userId);
    Assertions.assertThat(taskSummaryList.size()).isEqualTo(1);
    Long taskId = taskSummaryList.get(0).getId();
    for (int i = 1; i <= 50; i++) {
        ejb.addComment(taskId, COMMENT + " with sequence number #" + i, userId, new Date());
    }
    List<Comment> commentList = getComments(taskId);
    Assertions.assertThat(commentList).hasSize(50);
}
Also used : Comment(org.kie.api.task.model.Comment) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Date(java.util.Date) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 10 with Comment

use of org.kie.api.task.model.Comment in project jbpm by kiegroup.

the class LifeCycleBaseTest method testCompleteWithComments.

@Test
public void testCompleteWithComments() {
    // One potential owner, should go straight to state Reserved
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new User('Darth Vader') ],businessAdministrators = [ new User('Administrator') ], }),";
    str += "name = 'This is my task name' })";
    Task task = TaskFactory.evalTask(new StringReader(str));
    taskService.addTask(task, new HashMap<String, Object>());
    long taskId = task.getId();
    List<Comment> comments = taskService.getAllCommentsByTaskId(taskId);
    assertNotNull(comments);
    assertEquals(0, comments.size());
    User user = createUser("Bobba Fet");
    Comment comment = TaskModelProvider.getFactory().newComment();
    ((InternalComment) comment).setAddedAt(new Date());
    ((InternalComment) comment).setAddedBy(user);
    ((InternalComment) comment).setText("Simple test comment");
    taskService.addComment(taskId, comment);
    comments = taskService.getAllCommentsByTaskId(taskId);
    assertNotNull(comments);
    assertEquals(1, comments.size());
    // Go straight from Ready to Inprogress
    taskService.start(taskId, "Darth Vader");
    Task task1 = taskService.getTaskById(taskId);
    assertEquals(Status.InProgress, task1.getTaskData().getStatus());
    assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId());
    // Check is Complete
    taskService.complete(taskId, "Darth Vader", null);
    Task task2 = taskService.getTaskById(taskId);
    assertEquals(Status.Completed, task2.getTaskData().getStatus());
    assertEquals("Darth Vader", task2.getTaskData().getActualOwner().getId());
}
Also used : InternalComment(org.kie.internal.task.api.model.InternalComment) Comment(org.kie.api.task.model.Comment) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) User(org.kie.api.task.model.User) InternalComment(org.kie.internal.task.api.model.InternalComment) StringReader(java.io.StringReader) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Comment (org.kie.api.task.model.Comment)12 Test (org.junit.Test)7 Date (java.util.Date)5 User (org.kie.api.task.model.User)5 InternalComment (org.kie.internal.task.api.model.InternalComment)5 Task (org.kie.api.task.model.Task)4 TaskSummary (org.kie.api.task.model.TaskSummary)4 StringReader (java.io.StringReader)3 ArrayList (java.util.ArrayList)2 RemoteEjbTest (org.jbpm.remote.ejb.test.RemoteEjbTest)2 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)2 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)2 InternalTask (org.kie.internal.task.api.model.InternalTask)2 HashMap (java.util.HashMap)1 List (java.util.List)1 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)1 CommentImpl (org.jbpm.services.task.impl.model.CommentImpl)1 JaxbComment (org.jbpm.services.task.impl.model.xml.JaxbComment)1 Attachment (org.kie.api.task.model.Attachment)1 I18NText (org.kie.api.task.model.I18NText)1