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());
}
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;
}
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());
}
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);
}
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());
}
Aggregations