本文整理了Java中org.camunda.bpm.engine.task.Task.setParentTaskId()
方法的一些代码示例,展示了Task.setParentTaskId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.setParentTaskId()
方法的具体详情如下:
包路径:org.camunda.bpm.engine.task.Task
类名称:Task
方法名:setParentTaskId
[英]the parent task for which this task is a subtask
[中]此任务作为子任务的父任务
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testSaveTaskWithNonExistingParentTask() {
// given
Task task = taskService.newTask();
// when
task.setParentTaskId("non-existing");
// then
try {
taskService.saveTask(task);
fail("It should not be possible to save a task with a non existing parent task.");
} catch (NotValidException e) {}
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testStandaloneTaskGetSubTasksWithoutAuthorization() {
// given
String parentTaskId = "parentTaskId";
createTask(parentTaskId);
disableAuthorization();
Task sub1 = taskService.newTask("sub1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("sub2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
enableAuthorization();
// when
List<Task> subTasks = taskService.getSubTasks(parentTaskId);
// then
assertTrue(subTasks.isEmpty());
deleteTask(parentTaskId, true);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testQueryByParentTaskId() {
String parentTaskId = "parentTask";
Task parent = taskService.newTask(parentTaskId);
taskService.saveTask(parent);
Task sub1 = taskService.newTask("subTask1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("subTask2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
TaskQuery query = taskService.createTaskQuery().taskParentTaskId(parentTaskId);
verifyQueryResults(query, 2);
taskService.deleteTask(parentTaskId, true);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testCaseTaskGetSubTasksWithoutAuthorization() {
// given
createCaseInstanceByKey(CASE_KEY);
String parentTaskId = selectSingleTask().getId();
disableAuthorization();
Task sub1 = taskService.newTask("sub1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("sub2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
enableAuthorization();
// when
List<Task> subTasks = taskService.getSubTasks(parentTaskId);
// then
assertTrue(subTasks.isEmpty());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testProcessTaskGetSubTasksWithoutAuthorization() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String parentTaskId = selectSingleTask().getId();
disableAuthorization();
Task sub1 = taskService.newTask("sub1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("sub2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
enableAuthorization();
// when
List<Task> subTasks = taskService.getSubTasks(parentTaskId);
// then
assertTrue(subTasks.isEmpty());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testStandaloneTaskGetSubTasks() {
// given
String parentTaskId = "parentTaskId";
createTask(parentTaskId);
disableAuthorization();
Task sub1 = taskService.newTask("sub1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("sub2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
enableAuthorization();
createGrantAuthorization(TASK, ANY, userId, READ);
// when
List<Task> subTasks = taskService.getSubTasks(parentTaskId);
// then
assertFalse(subTasks.isEmpty());
assertEquals(2, subTasks.size());
deleteTask(parentTaskId, true);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testCaseTaskGetSubTasks() {
// given
createCaseInstanceByKey(CASE_KEY);
String parentTaskId = selectSingleTask().getId();
disableAuthorization();
Task sub1 = taskService.newTask("sub1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("sub2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
enableAuthorization();
createGrantAuthorization(TASK, ANY, userId, READ);
// when
List<Task> subTasks = taskService.getSubTasks(parentTaskId);
// then
assertFalse(subTasks.isEmpty());
assertEquals(2, subTasks.size());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testProcessTaskGetSubTasks() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String parentTaskId = selectSingleTask().getId();
disableAuthorization();
Task sub1 = taskService.newTask("sub1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("sub2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
enableAuthorization();
createGrantAuthorization(TASK, ANY, userId, READ);
// when
List<Task> subTasks = taskService.getSubTasks(parentTaskId);
// then
assertFalse(subTasks.isEmpty());
assertEquals(2, subTasks.size());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testProcessTaskGetSubTasksWithReadPermissionOnSub1() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String parentTaskId = selectSingleTask().getId();
disableAuthorization();
Task sub1 = taskService.newTask("sub1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("sub2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
enableAuthorization();
createGrantAuthorization(TASK, "sub1", userId, READ);
// when
List<Task> subTasks = taskService.getSubTasks(parentTaskId);
// then
assertFalse(subTasks.isEmpty());
assertEquals(1, subTasks.size());
assertEquals("sub1", subTasks.get(0).getId());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testCaseTaskGetSubTasksWithReadPermissionOnSub1() {
// given
createCaseInstanceByKey(CASE_KEY);
String parentTaskId = selectSingleTask().getId();
disableAuthorization();
Task sub1 = taskService.newTask("sub1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("sub2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
enableAuthorization();
createGrantAuthorization(TASK, "sub1", userId, READ);
// when
List<Task> subTasks = taskService.getSubTasks(parentTaskId);
// then
assertFalse(subTasks.isEmpty());
assertEquals(1, subTasks.size());
assertEquals("sub1", subTasks.get(0).getId());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testStandaloneTaskCannotSetDifferentTenantIdOnSubTaskWithNull() {
// given a persistent task without tenant id
Task task = taskService.newTask();
taskService.saveTask(task);
// if
// I create a subtask with a different tenant id
Task subTask = taskService.newTask();
subTask.setParentTaskId(task.getId());
subTask.setTenantId(tenant1);
// then an exception is thrown on save
try {
taskService.saveTask(subTask);
fail("Exception expected.");
}
catch(ProcessEngineException e) {
assertTextPresent("ENGINE-03073 Cannot set different tenantId on subtask than on parent Task", e.getMessage());
}
// Finally, delete task
deleteTasks(task);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testSaveTaskSetParentTaskId() {
// given
Task parent = taskService.newTask("parent");
taskService.saveTask(parent);
Task task = taskService.newTask("subTask");
// when
task.setParentTaskId("parent");
// then
taskService.saveTask(task);
// update task
task = taskService.createTaskQuery().taskId("subTask").singleResult();
assertEquals(parent.getId(), task.getParentTaskId());
taskService.deleteTask("parent", true);
taskService.deleteTask("subTask", true);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void updateTask(Task task) {
task.setName(getName());
task.setDescription(getDescription());
task.setPriority(getPriority());
task.setAssignee(getAssignee());
task.setOwner(getOwner());
DelegationState state = null;
if (getDelegationState() != null) {
DelegationStateConverter converter = new DelegationStateConverter();
state = converter.convertQueryParameterToType(getDelegationState());
}
task.setDelegationState(state);
task.setDueDate(getDue());
task.setFollowUpDate(getFollowUp());
task.setParentTaskId(getParentTaskId());
task.setCaseInstanceId(getCaseInstanceId());
task.setTenantId(getTenantId());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void updateTask(Task task) {
task.setName(getName());
task.setDescription(getDescription());
task.setPriority(getPriority());
task.setAssignee(getAssignee());
task.setOwner(getOwner());
DelegationState state = null;
if (getDelegationState() != null) {
DelegationStateConverter converter = new DelegationStateConverter();
state = converter.convertQueryParameterToType(getDelegationState());
}
task.setDelegationState(state);
task.setDueDate(getDue());
task.setFollowUpDate(getFollowUp());
task.setParentTaskId(getParentTaskId());
task.setCaseInstanceId(getCaseInstanceId());
task.setTenantId(getTenantId());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testStandaloneTaskCannotSetDifferentTenantIdOnSubTask() {
// given a persistent task with a tenant id
Task task = taskService.newTask();
task.setTenantId(tenant1);
taskService.saveTask(task);
// if
// I create a subtask with a different tenant id
Task subTask = taskService.newTask();
subTask.setParentTaskId(task.getId());
subTask.setTenantId(tenant2);
// then an exception is thrown on save
try {
taskService.saveTask(subTask);
fail("Exception expected.");
}
catch(ProcessEngineException e) {
assertTextPresent("ENGINE-03073 Cannot set different tenantId on subtask than on parent Task", e.getMessage());
}
// Finally, delete task
deleteTasks(task);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testStandaloneTaskPropagateTenantIdToSubTask() {
// given a persistent task with a tenant id
Task task = taskService.newTask();
task.setTenantId(tenant1);
taskService.saveTask(task);
// if
// I create a subtask without tenant id
Task subTask = taskService.newTask();
subTask.setParentTaskId(task.getId());
taskService.saveTask(subTask);
// then
// the parent task's tenant id is propagated to the sub task
subTask = taskService.createTaskQuery().taskId(subTask.getId()).singleResult();
assertEquals(tenant1, subTask.getTenantId());
// Finally, delete task
deleteTasks(subTask, task);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testSubTaskCreationFailAfterProcessInstanceSuspendByProcessDefinitionId() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinition.getId());
Task subTask = taskService.newTask("someTaskId");
subTask.setParentTaskId(task.getId());
try {
taskService.saveTask(subTask);
fail("Creating sub tasks for suspended task should not be possible");
} catch (SuspendedEntityInteractionException e) {
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testSubTaskCreationFailAfterProcessInstanceSuspend() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
runtimeService.suspendProcessInstanceById(processInstance.getId());
Task subTask = taskService.newTask("someTaskId");
subTask.setParentTaskId(task.getId());
try {
taskService.saveTask(subTask);
fail("Creating sub tasks for suspended task should not be possible");
} catch (SuspendedEntityInteractionException e) {
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testSubTaskCreationFailAfterProcessInstanceSuspendByProcessDefinitionKey() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
Task subTask = taskService.newTask("someTaskId");
subTask.setParentTaskId(task.getId());
try {
taskService.saveTask(subTask);
fail("Creating sub tasks for suspended task should not be possible");
} catch (SuspendedEntityInteractionException e) {
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
@Deployment
public void testSubTaskData() {
//given simple process with user task
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subTaskTest");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
// when set variable to user task
taskService.setVariable(task.getId(), "testVariable", "testValue");
// then variable is set in the scope of execution
Assert.assertEquals("testValue", runtimeService.getVariable(task.getExecutionId(), "testVariable"));
// when sub task is created create subtask for user task
Task subTask = taskService.newTask("123456789");
subTask.setParentTaskId(task.getId());
subTask.setName("Test Subtask");
taskService.saveTask(subTask);
// and variable is update
taskService.setVariable(subTask.getId(), "testVariable", "newTestValue");
//then variable is also updated in the scope execution
Assert.assertEquals("newTestValue", runtimeService.getVariable(task.getExecutionId(), "testVariable"));
}
}
内容来源于网络,如有侵权,请联系作者删除!