Skip to content

Commit

Permalink
[JBPM-10081] Task Description field is set with the same value of Tas…
Browse files Browse the repository at this point in the history
…k Subject.
  • Loading branch information
abhijithumbe committed Aug 4, 2022
1 parent 6a11ad7 commit c2b1d03
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
Expand Up @@ -60,6 +60,8 @@ public abstract class AbstractHTWorkItemHandler implements WorkItemHandler {

protected static final String ADMIN_USER = System.getProperty("org.jbpm.ht.admin.user", "Administrator");

protected static final Boolean COPY_TASK_SUBJECT_TO_Task_DESCRIPTION = Boolean.parseBoolean(System.getProperty("org.jbpm.ht.copy.task_subject.to.task_description", "true"));

protected OnErrorAction action = OnErrorAction.LOG;

public AbstractHTWorkItemHandler() {
Expand Down Expand Up @@ -107,7 +109,12 @@ protected Task createTaskBasedOnWorkItemParams(KieSession session, WorkItem work

String description = (String) workItem.getParameter("Description");
if (description == null) {
description = comment;
if (COPY_TASK_SUBJECT_TO_Task_DESCRIPTION) {
description = comment;
} else {
description = "";
}

}

List<I18NText> descriptions = new ArrayList<I18NText>();
Expand Down
Expand Up @@ -129,6 +129,82 @@ public void testTaskMultipleActors() throws Exception {
assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
}

@Test
public void testTaskDescriptinCopyingFromTaskSubject() throws Exception {

System.setProperty("org.jbpm.ht.copy.task_subject.to.task_description", "true");

TestWorkItemManager manager = new TestWorkItemManager();
ksession.setWorkItemManager(manager);
WorkItemImpl workItem = new WorkItemImpl();
workItem.setName("Human Task");
workItem.setParameter("NodeName", "TaskName");
workItem.setParameter("Comment", "Comment");
workItem.setParameter("Priority", "10");
workItem.setParameter("ActorId", "Darth Vader, Dalai Lama");
workItem.setProcessInstanceId(10);
getHandler().executeWorkItem(workItem, manager);


List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
assertEquals(1, tasks.size());
TaskSummary task = tasks.get(0);
assertEquals("TaskName", task.getName());
assertEquals(10, task.getPriority().intValue());
assertEquals("Comment", task.getSubject());
assertEquals("Comment", task.getDescription());
assertEquals(Status.Ready, task.getStatus());

taskService.claim(task.getId(), "Darth Vader");

taskService.start(task.getId(), "Darth Vader");

taskService.complete(task.getId(), "Darth Vader", null);

assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));

System.clearProperty("org.jbpm.ht.copy.task_subject.to.task_description");
}

@Test
public void testTaskDescriptinWithoutCopyingFromTaskSubject() throws Exception {

System.setProperty("org.jbpm.ht.copy.task_subject.to.task_description", "false");

TestWorkItemManager manager = new TestWorkItemManager();
ksession.setWorkItemManager(manager);
WorkItemImpl workItem = new WorkItemImpl();
workItem.setName("Human Task");
workItem.setParameter("NodeName", "TaskName");
workItem.setParameter("Comment", "Comment");
workItem.setParameter("Description", "Description");
workItem.setParameter("Priority", "10");
workItem.setParameter("ActorId", "Darth Vader, Dalai Lama");
workItem.setProcessInstanceId(10);
getHandler().executeWorkItem(workItem, manager);


List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
assertEquals(1, tasks.size());
TaskSummary task = tasks.get(0);
assertEquals("TaskName", task.getName());
assertEquals(10, task.getPriority().intValue());
assertEquals("Comment", task.getSubject());
assertEquals("Description", task.getDescription());
assertEquals(Status.Ready, task.getStatus());

taskService.claim(task.getId(), "Darth Vader");

taskService.start(task.getId(), "Darth Vader");

taskService.complete(task.getId(), "Darth Vader", null);

assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));

System.clearProperty("org.jbpm.ht.copy.task_subject.to.task_description");

}

@Test
public void testTaskGroupActors() throws Exception {

Expand Down

0 comments on commit c2b1d03

Please sign in to comment.