variableMap.put("name", "Activiti");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Unclaim", variableMap);
assertNotNull(processInstance.getId());
System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
TaskService taskService = activitiRule.getTaskService();
assertEquals(taskService.createTaskQuery().taskCandidateUser("user1").count(), 1);
assertEquals(taskService.createTaskQuery().taskCandidateUser("user2").count(), 1);
assertEquals(taskService.createTaskQuery().taskCandidateUser("user3").count(), 1);
Task task = taskService.createTaskQuery().singleResult();
taskService.claim(task.getId(), "user1");
assertEquals(taskService.createTaskQuery().taskCandidateUser("user1").count(), 0);
assertEquals(taskService.createTaskQuery().taskCandidateUser("user2").count(), 0);
assertEquals(taskService.createTaskQuery().taskCandidateUser("user3").count(), 0);
ManagementService managementService = activitiRule.getManagementService();
TablePage listPage = managementService.createTablePageQuery().tableName(managementService.getTableName(IdentityLinkEntity.class)).listPage(0, 100);
List<Map<String, Object>> rows = listPage.getRows();
for (Map<String, Object> map : rows) {
Set<Entry<String, Object>> entrySet = map.entrySet();
for (Entry<String, Object> entry : entrySet) {
// System.out.println("key=" + entry.getKey() + ", value=" +
if (entry.getKey().equals("TYPE_")) {
assertTrue(ArrayUtils.contains(new String[] { "user1", "user2", "user3" }, map.get("USER_ID_").toString()));
}
}
}
// unclaim
taskService.setAssignee(task.getId(), null);
assertEquals(taskService.createTaskQuery().taskCandidateUser("user1").count(), 1);
assertEquals(taskService.createTaskQuery().taskCandidateUser("user2").count(), 1);
assertEquals(taskService.createTaskQuery().taskCandidateUser("user3").count(), 1);
}