Source:
public void testProcessWithUserTasks() throws Exception { Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK); assertNotNull(processInstanceId); assertTrue(processInstanceId.longValue() > 0); try { List<TaskSummary> taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertNotNull(taskList); assertEquals(1, taskList.size()); TaskSummary taskSummary = taskList.get(0); assertEquals("First task", taskSummary.getName()); taskClient.startTask(CONTAINER_ID, taskSummary.getId(), USER_YODA); Map<String, Object> taskOutcome = new HashMap<String, Object>(); taskOutcome.put("string_", "my custom data"); taskOutcome.put("person_", createPersonInstance(USER_MARY)); Map<String, Object> content = new HashMap<>(); content.put("name", "joda"); taskClient.saveTaskContent(CONTAINER_ID, taskSummary.getId(), "admin", content); List<TaskEventInstance> events = taskClient.findTaskEvents(taskSummary.getId(), 0, 10); assertEquals("admin", events.get(events.size() - 1).getUserId()); taskClient.saveTaskContent(CONTAINER_ID, taskSummary.getId(), "other", content); events = taskClient.findTaskEvents(taskSummary.getId(), 0, 10); assertEquals("other", events.get(events.size() - 1).getUserId()); taskClient.completeTask(CONTAINER_ID, taskSummary.getId(), USER_YODA, taskOutcome); Object personVar = processClient.getProcessInstanceVariable(CONTAINER_ID, processInstanceId, "personData"); assertNotNull(personVar); assertEquals(USER_MARY, KieServerReflections.valueOf(personVar, "name")); String stringVar = (String) processClient.getProcessInstanceVariable(CONTAINER_ID, processInstanceId, "stringData"); assertNotNull(personVar); assertEquals("my custom data", stringVar); taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertNotNull(taskList); assertEquals(1, taskList.size()); taskSummary = taskList.get(0); assertEquals("Second task", taskSummary.getName()); } finally { processClient.abortProcessInstance(CONTAINER_ID, processInstanceId); } }

Target:
public void testProcessWithUserTasks() { Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK2); assertNotNull(processInstanceId); assertTrue(processInstanceId > 0); try { List<TaskSummary> taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertNotNull(taskList); assertEquals(1, taskList.size()); TaskSummary taskSummary = taskList.get(0); assertEquals("First task", taskSummary.getName()); taskClient.startTask(CONTAINER_ID, taskSummary.getId(), USER_YODA); Map<String, Object> taskOutcome = new HashMap<String, Object>(); taskOutcome.put("string_", "my custom data"); Map<String, Object> content = new HashMap<>(); content.put("name", "joda"); taskClient.saveTaskContent(CONTAINER_ID, taskSummary.getId(), "admin", content); List<TaskEventInstance> events = taskClient.findTaskEvents(taskSummary.getId(), 0, 10); assertEquals("admin", events.get(events.size() - 1).getUserId()); taskClient.saveTaskContent(CONTAINER_ID, taskSummary.getId(), "other", content); events = taskClient.findTaskEvents(taskSummary.getId(), 0, 10); assertEquals("other", events.get(events.size() - 1).getUserId()); taskClient.completeTask(CONTAINER_ID, taskSummary.getId(), USER_YODA, taskOutcome); String stringVar = (String) processClient.getProcessInstanceVariable(CONTAINER_ID, processInstanceId, "stringData"); assertNotNull(stringVar); assertEquals("my custom data", stringVar); taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertNotNull(taskList); assertEquals(1, taskList.size()); taskSummary = taskList.get(0); assertEquals("Second task", taskSummary.getName()); } finally { processClient.abortProcessInstance(CONTAINER_ID, processInstanceId); } }