Java Code Examples for org.activiti.engine.task.Task#setOwner()
The following examples show how to use
org.activiti.engine.task.Task#setOwner() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testQueryByInvolvedUserOr() { try { Task adhocTask = taskService.newTask(); adhocTask.setAssignee("kermit"); adhocTask.setOwner("fozzie"); taskService.saveTask(adhocTask); taskService.addUserIdentityLink(adhocTask.getId(), "gonzo", "customType"); assertEquals(3, taskService.getIdentityLinksForTask(adhocTask.getId()).size()); assertEquals(1, taskService.createTaskQuery().taskId(adhocTask.getId()).or().taskId("invalid").taskInvolvedUser("gonzo").count()); assertEquals(1, taskService.createTaskQuery().taskId(adhocTask.getId()).or().taskId("invalid").taskInvolvedUser("kermit").count()); assertEquals(1, taskService.createTaskQuery().taskId(adhocTask.getId()).or().taskId("invalid").taskInvolvedUser("fozzie").count()); } finally { List<Task> allTasks = taskService.createTaskQuery().list(); for (Task task : allTasks) { if (task.getExecutionId() == null) { taskService.deleteTask(task.getId()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(task.getId()); } } } } }
Example 2
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testQueryByInvolvedGroup() { try { Task adhocTask = taskService.newTask(); adhocTask.setAssignee("kermit"); adhocTask.setOwner("fozzie"); taskService.saveTask(adhocTask); taskService.addGroupIdentityLink(adhocTask.getId(), "group1", IdentityLinkType.PARTICIPANT); List<String> groups = new ArrayList<String>(); groups.add("group1"); assertEquals(3, taskService.getIdentityLinksForTask(adhocTask.getId()).size()); assertEquals(1, taskService.createTaskQuery() .taskId(adhocTask.getId()).taskInvolvedGroupsIn(groups).count()); } finally { List<Task> allTasks = taskService.createTaskQuery().list(); for (Task task : allTasks) { if (task.getExecutionId() == null) { taskService.deleteTask(task.getId()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(task.getId()); } } } } }
Example 3
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testQueryByInvolvedUser() { try { Task adhocTask = taskService.newTask(); adhocTask.setAssignee("kermit"); adhocTask.setOwner("fozzie"); taskService.saveTask(adhocTask); taskService.addUserIdentityLink(adhocTask.getId(), "gonzo", "customType"); assertEquals(3, taskService.getIdentityLinksForTask(adhocTask.getId()).size()); assertEquals(1, taskService.createTaskQuery().taskId(adhocTask.getId()).taskInvolvedUser("gonzo").count()); assertEquals(1, taskService.createTaskQuery().taskId(adhocTask.getId()).taskInvolvedUser("kermit").count()); assertEquals(1, taskService.createTaskQuery().taskId(adhocTask.getId()).taskInvolvedUser("fozzie").count()); } finally { List<Task> allTasks = taskService.createTaskQuery().list(); for(Task task : allTasks) { if(task.getExecutionId() == null) { taskService.deleteTask(task.getId()); if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(task.getId()); } } } } }
Example 4
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testTaskDelegationThroughServiceCall() { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); String taskId = task.getId(); // Fetch the task again and update task = taskService.createTaskQuery().taskId(taskId).singleResult(); taskService.delegateTask(task.getId(), "joesmoe"); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("joesmoe", task.getAssignee()); assertEquals(DelegationState.PENDING, task.getDelegationState()); taskService.resolveTask(taskId); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("johndoe", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); // Finally, delete task taskService.deleteTask(taskId, true); }
Example 5
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testTaskOwner() { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); // Fetch the task again and update task = taskService.createTaskQuery().taskId(task.getId()).singleResult(); assertEquals("johndoe", task.getOwner()); task.setOwner("joesmoe"); taskService.saveTask(task); task = taskService.createTaskQuery().taskId(task.getId()).singleResult(); assertEquals("joesmoe", task.getOwner()); // Finally, delete task taskService.deleteTask(task.getId(), true); }
Example 6
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * @see <a href="https://activiti.atlassian.net/browse/ACT-1059">https://activiti.atlassian.net/browse/ACT-1059</a> */ public void testSetDelegationState() { Task task = taskService.newTask(); task.setOwner("wuzh"); taskService.saveTask(task); taskService.delegateTask(task.getId(), "other"); String taskId = task.getId(); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("wuzh", task.getOwner()); assertEquals("other", task.getAssignee()); assertEquals(DelegationState.PENDING, task.getDelegationState()); task.setDelegationState(DelegationState.RESOLVED); taskService.saveTask(task); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("wuzh", task.getOwner()); assertEquals("other", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); taskService.deleteTask(taskId, true); }
Example 7
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testTaskAttachments() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); String taskId = task.getId(); identityService.setAuthenticatedUserId("johndoe"); // Fetch the task again and update taskService.createAttachment("web page", taskId, null, "weatherforcast", "temperatures and more", "http://weather.com"); Attachment attachment = taskService.getTaskAttachments(taskId).get(0); assertEquals("weatherforcast", attachment.getName()); assertEquals("temperatures and more", attachment.getDescription()); assertEquals("web page", attachment.getType()); assertEquals(taskId, attachment.getTaskId()); assertNull(attachment.getProcessInstanceId()); assertEquals("http://weather.com", attachment.getUrl()); assertNull(taskService.getAttachmentContent(attachment.getId())); // Finally, clean up taskService.deleteTask(taskId); assertEquals(0, taskService.getTaskComments(taskId).size()); assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskId(taskId).list().size()); taskService.deleteTask(taskId, true); } }
Example 8
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testTaskAttachments() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); String taskId = task.getId(); identityService.setAuthenticatedUserId("johndoe"); // Fetch the task again and update taskService.createAttachment("web page", taskId, null, "weatherforcast", "temperatures and more", "http://weather.com"); Attachment attachment = taskService.getTaskAttachments(taskId).get(0); assertEquals("weatherforcast", attachment.getName()); assertEquals("temperatures and more", attachment.getDescription()); assertEquals("web page", attachment.getType()); assertEquals(taskId, attachment.getTaskId()); assertNull(attachment.getProcessInstanceId()); assertEquals("http://weather.com", attachment.getUrl()); assertNull(taskService.getAttachmentContent(attachment.getId())); // Finally, clean up taskService.deleteTask(taskId); assertEquals(0, taskService.getTaskComments(taskId).size()); assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskId(taskId).list().size()); taskService.deleteTask(taskId, true); } }
Example 9
Source File: TaskIdentityLinksTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testDeleteOwner() { Task task = taskService.newTask(); task.setOwner("nonExistingUser"); taskService.saveTask(task); taskService.deleteUserIdentityLink(task.getId(), "nonExistingUser", IdentityLinkType.OWNER); task = taskService.createTaskQuery().taskId(task.getId()).singleResult(); assertNull(task.getOwner()); assertEquals(0, taskService.getIdentityLinksForTask(task.getId()).size()); // cleanup taskService.deleteTask(task.getId(), true); }
Example 10
Source File: ActivitiTestBase.java From crnk-framework with Apache License 2.0 | 5 votes |
protected Task addTask(String name, int priority) { TaskService taskService = processEngine.getTaskService(); Task task = taskService.newTask(); task.setName(name); task.setPriority(priority); task.setAssignee("john"); task.setCategory("testCategory"); task.setDueDate(new Date()); task.setOwner("jane"); task.setDescription("testDescription"); task.setTenantId("testTenant"); taskService.saveTask(task); return task; }
Example 11
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testSaveTaskAttachment() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); String taskId = task.getId(); identityService.setAuthenticatedUserId("johndoe"); // Fetch attachment and update its name taskService.createAttachment("web page", taskId, null, "weatherforcast", "temperatures and more", "http://weather.com"); Attachment attachment = taskService.getTaskAttachments(taskId).get(0); attachment.setName("UpdatedName"); taskService.saveAttachment(attachment); // Refetch and verify attachment = taskService.getTaskAttachments(taskId).get(0); assertEquals("UpdatedName", attachment.getName()); // Finally, clean up taskService.deleteTask(taskId); assertEquals(0, taskService.getTaskComments(taskId).size()); assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskId(taskId).list().size()); taskService.deleteTask(taskId, true); } }
Example 12
Source File: TaskController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 添加子任务 */ @RequestMapping("task/subtask/add/{taskId}") public String addSubTask(@PathVariable("taskId") String parentTaskId, @RequestParam("taskName") String taskName, @RequestParam(value = "description", required = false) String description, HttpSession session) { Task newTask = taskService.newTask(); newTask.setParentTaskId(parentTaskId); String userId = UserUtil.getUserFromSession(session).getId(); newTask.setOwner(userId); newTask.setAssignee(userId); newTask.setName(taskName); newTask.setDescription(description); taskService.saveTask(newTask); return "redirect:/chapter6/task/getform/" + parentTaskId; }
Example 13
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testQueryByInvolvedUser() { try { Task adhocTask = taskService.newTask(); adhocTask.setAssignee("kermit"); adhocTask.setOwner("fozzie"); taskService.saveTask(adhocTask); taskService.addUserIdentityLink(adhocTask.getId(), "gonzo", "customType"); assertEquals(3, taskService.getIdentityLinksForTask(adhocTask.getId()).size()); assertEquals(1, taskService.createTaskQuery() .taskId(adhocTask.getId()).taskInvolvedUser("gonzo").count()); assertEquals(1, taskService.createTaskQuery().taskId(adhocTask.getId()).taskInvolvedUser("kermit").count()); assertEquals(1, taskService.createTaskQuery().taskId(adhocTask.getId()).taskInvolvedUser("fozzie").count()); } finally { List<Task> allTasks = taskService.createTaskQuery().list(); for(Task task : allTasks) { if(task.getExecutionId() == null) { taskService.deleteTask(task.getId()); if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(task.getId()); } } } } }
Example 14
Source File: TaskController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 更改任务属性 * * @throws ParseException */ @RequestMapping("task/property/{taskId}") @ResponseBody public String changeTaskProperty(@PathVariable("taskId") String taskId, @RequestParam("propertyName") String propertyName, @RequestParam("value") String value) throws ParseException { Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); // 更改到期日 if (StringUtils.equals(propertyName, "dueDate")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date parse = sdf.parse(value); task.setDueDate(parse); taskService.saveTask(task); } else if (StringUtils.equals(propertyName, "priority")) { // 更改任务优先级 task.setPriority(Integer.parseInt(value)); taskService.saveTask(task); } else if (StringUtils.equals(propertyName, "owner")) { // 更改拥有人 task.setOwner(value); taskService.saveTask(task); } else if (StringUtils.equals(propertyName, "assignee")) { // 更改办理人 task.setAssignee(value); taskService.saveTask(task); } else { return "不支持[" + propertyName + "]属性!"; } return "success"; }
Example 15
Source File: TaskQueryResourceTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
/** * Test querying tasks. GET runtime/tasks */ public void testQueryTasksWithPaging() throws Exception { try { Calendar adhocTaskCreate = Calendar.getInstance(); adhocTaskCreate.set(Calendar.MILLISECOND, 0); processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime()); List<String> taskIdList = new ArrayList<String>(); for (int i = 0; i < 10; i++) { Task adhocTask = taskService.newTask(); adhocTask.setAssignee("gonzo"); adhocTask.setOwner("owner"); adhocTask.setDelegationState(DelegationState.PENDING); adhocTask.setDescription("Description one"); adhocTask.setName("Name one"); adhocTask.setDueDate(adhocTaskCreate.getTime()); adhocTask.setPriority(100); taskService.saveTask(adhocTask); taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT); taskIdList.add(adhocTask.getId()); } Collections.sort(taskIdList); // Check filter-less to fetch all tasks String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY); ObjectNode requestNode = objectMapper.createObjectNode(); String[] taskIds = new String[] { taskIdList.get(0), taskIdList.get(1), taskIdList.get(2) }; assertResultsPresentInPostDataResponse(url + "?size=3&sort=id&order=asc", requestNode, taskIds); taskIds = new String[] { taskIdList.get(4), taskIdList.get(5), taskIdList.get(6), taskIdList.get(7) }; assertResultsPresentInPostDataResponse(url + "?start=4&size=4&sort=id&order=asc", requestNode, taskIds); taskIds = new String[] { taskIdList.get(8), taskIdList.get(9) }; assertResultsPresentInPostDataResponse(url + "?start=8&size=10&sort=id&order=asc", requestNode, taskIds); } finally { // Clean adhoc-tasks even if test fails List<Task> tasks = taskService.createTaskQuery().list(); for (Task task : tasks) { if (task.getExecutionId() == null) { taskService.deleteTask(task.getId(), true); } } } }
Example 16
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testTaskDelegation() { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); taskService.delegateTask(task.getId(), "joesmoe"); String taskId = task.getId(); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("joesmoe", task.getAssignee()); assertEquals(DelegationState.PENDING, task.getDelegationState()); // try to complete (should fail) try { taskService.complete(task.getId()); fail(); } catch (ActivitiException e) { } taskService.resolveTask(taskId); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("johndoe", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); task.setAssignee(null); task.setDelegationState(null); taskService.saveTask(task); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertNull(task.getAssignee()); assertNull(task.getDelegationState()); task.setAssignee("jackblack"); task.setDelegationState(DelegationState.RESOLVED); taskService.saveTask(task); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("jackblack", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); // Finally, delete task taskService.deleteTask(taskId, true); }
Example 17
Source File: TaskInvolvementTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testQueryMultipleAndAndSingleOr() { try { Task taskUser1Group1 = taskService.newTask(); taskUser1Group1.setAssignee("kermit"); taskUser1Group1.setOwner("user1"); taskUser1Group1.setPriority(10); taskService.saveTask(taskUser1Group1); taskService.addGroupIdentityLink(taskUser1Group1.getId(), "group1", IdentityLinkType.PARTICIPANT); Task taskUser1Group2 = taskService.newTask(); taskUser1Group2.setAssignee("kermit"); taskUser1Group2.setOwner("user1"); taskUser1Group2.setPriority(10); taskService.saveTask(taskUser1Group2); taskService.addGroupIdentityLink(taskUser1Group2.getId(), "group2", IdentityLinkType.PARTICIPANT); Task taskUser1Group1and2 = taskService.newTask(); taskUser1Group1and2.setAssignee("kermit"); taskUser1Group1and2.setOwner("user1"); taskUser1Group1and2.setPriority(10); taskService.saveTask(taskUser1Group1and2); taskService.addGroupIdentityLink(taskUser1Group2.getId(), "group1", IdentityLinkType.PARTICIPANT); taskService.addGroupIdentityLink(taskUser1Group2.getId(), "group2", IdentityLinkType.PARTICIPANT); Task taskUser1Group1and3 = taskService.newTask(); taskUser1Group1and3.setAssignee("kermit"); taskUser1Group1and3.setOwner("user1"); taskUser1Group1and3.setPriority(10); taskService.saveTask(taskUser1Group1and3); taskService.addGroupIdentityLink(taskUser1Group1and3.getId(), "group1", IdentityLinkType.PARTICIPANT); taskService.addGroupIdentityLink(taskUser1Group1and3.getId(), "group3", IdentityLinkType.PARTICIPANT); Task taskUser1Group1and4 = taskService.newTask(); taskUser1Group1and4.setAssignee("kermit"); taskUser1Group1and4.setOwner("user1"); taskUser1Group1and4.setPriority(10); taskService.saveTask(taskUser1Group1and4); taskService.addGroupIdentityLink(taskUser1Group1and4.getId(), "group1", IdentityLinkType.PARTICIPANT); taskService.addGroupIdentityLink(taskUser1Group1and4.getId(), "group4", IdentityLinkType.PARTICIPANT); List<String> andGroup = new ArrayList<String>(); andGroup.add("group1"); List<String> orGroup = new ArrayList<String>(); orGroup.add("group2"); orGroup.add("group4"); assertEquals(2, taskService.createTaskQuery() .taskInvolvedUser("user1") .taskInvolvedGroupsIn(andGroup) .or().taskInvolvedGroupsIn(orGroup).endOr() .count()); } finally { List<Task> allTasks = taskService.createTaskQuery().list(); for(Task task : allTasks) { if(task.getExecutionId() == null) { taskService.deleteTask(task.getId()); if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(task.getId()); } } } } }
Example 18
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testTaskDelegation() { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); taskService.delegateTask(task.getId(), "joesmoe"); String taskId = task.getId(); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("joesmoe", task.getAssignee()); assertEquals(DelegationState.PENDING, task.getDelegationState()); // try to complete (should fail) try { taskService.complete(task.getId()); fail(); } catch (ActivitiException e) {} taskService.resolveTask(taskId); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("johndoe", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); task.setAssignee(null); task.setDelegationState(null); taskService.saveTask(task); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertNull(task.getAssignee()); assertNull(task.getDelegationState()); task.setAssignee("jackblack"); task.setDelegationState(DelegationState.RESOLVED); taskService.saveTask(task); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("jackblack", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); // Finally, delete task taskService.deleteTask(taskId, true); }
Example 19
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testCustomTaskComments() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); String taskId = task.getId(); identityService.setAuthenticatedUserId("johndoe"); String customType1 = "Type1"; String customType2 = "Type2"; Comment comment = taskService.addComment(taskId, null, "This is a regular comment"); Comment customComment1 = taskService.addComment(taskId, null, customType1, "This is a custom comment of type Type1"); Comment customComment2 = taskService.addComment(taskId, null, customType1, "This is another Type1 comment"); Comment customComment3 = taskService.addComment(taskId, null, customType2, "This is another custom comment. Type2 this time!"); assertEquals(CommentEntity.TYPE_COMMENT, comment.getType()); assertEquals(customType1, customComment1.getType()); assertEquals(customType2, customComment3.getType()); assertNotNull(taskService.getComment(comment.getId())); assertNotNull(taskService.getComment(customComment1.getId())); List<Comment> regularComments = taskService.getTaskComments(taskId); assertEquals(1, regularComments.size()); assertEquals("This is a regular comment", regularComments.get(0).getFullMessage()); List<Event> allComments = taskService.getTaskEvents(taskId); assertEquals(4, allComments.size()); List<Comment> type2Comments = taskService.getCommentsByType(customType2); assertEquals(1, type2Comments.size()); assertEquals("This is another custom comment. Type2 this time!", type2Comments.get(0).getFullMessage()); List<Comment> taskTypeComments = taskService.getTaskComments(taskId, customType1); assertEquals(2, taskTypeComments.size()); // Clean up taskService.deleteTask(taskId, true); } }
Example 20
Source File: TaskInvolvementTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testQueryByInvolvedGroupOrUserO() { try { Task adhocTask = taskService.newTask(); adhocTask.setAssignee("kermit"); adhocTask.setOwner("involvedUser"); adhocTask.setPriority(10); taskService.saveTask(adhocTask); List<String> groups = new ArrayList<String>(); groups.add("group1"); assertEquals(1, taskService.createTaskQuery() .or() .taskInvolvedUser("involvedUser") .taskInvolvedGroupsIn(groups) .endOr() .count()); if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { assertEquals(1, historyService.createHistoricTaskInstanceQuery() .or() .taskInvolvedUser("involvedUser") .taskInvolvedGroupsIn(groups) .endOr() .count()); } } finally { List<Task> allTasks = taskService.createTaskQuery().list(); for(Task task : allTasks) { if(task.getExecutionId() == null) { taskService.deleteTask(task.getId()); if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(task.getId()); } } } } }