Java Code Examples for org.camunda.bpm.engine.task.Task#setParentTaskId()
The following examples show how to use
org.camunda.bpm.engine.task.Task#setParentTaskId() .
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: MultiTenancyTaskServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: TaskServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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); }
Example 3
Source File: SubTaskDataTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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")); }
Example 4
Source File: ProcessInstanceSuspensionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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) { } }
Example 5
Source File: ProcessInstanceSuspensionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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) { } }
Example 6
Source File: ProcessInstanceSuspensionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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) { } }
Example 7
Source File: TaskDto.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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()); }
Example 8
Source File: TaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); }
Example 9
Source File: TaskAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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()); }
Example 10
Source File: TaskAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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()); }
Example 11
Source File: TaskAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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()); }
Example 12
Source File: TaskAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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()); }
Example 13
Source File: TaskAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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()); }
Example 14
Source File: TaskAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); }
Example 15
Source File: TaskAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); }
Example 16
Source File: MultiTenancyTaskServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); }
Example 17
Source File: MultiTenancyTaskServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); }
Example 18
Source File: MigrationHistoricTaskInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY) public void testMigrateWithSubTask() { //given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapEqualActivities() .build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId()); Task task = taskService.createTaskQuery().singleResult(); Task subTask = taskService.newTask(); subTask.setParentTaskId(task.getId()); taskService.saveTask(subTask); // when runtimeService.newMigration(migrationPlan) .processInstanceIds(Arrays.asList(processInstance.getId())) .execute(); // then the historic sub task instance is still the same HistoricTaskInstance historicSubTaskAfterMigration = historyService .createHistoricTaskInstanceQuery().taskId(subTask.getId()).singleResult(); Assert.assertNotNull(historicSubTaskAfterMigration); Assert.assertNull(historicSubTaskAfterMigration.getProcessDefinitionId()); Assert.assertNull(historicSubTaskAfterMigration.getProcessDefinitionKey()); Assert.assertNull(historicSubTaskAfterMigration.getExecutionId()); Assert.assertNull(historicSubTaskAfterMigration.getActivityInstanceId()); }
Example 19
Source File: TaskAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testStandaloneTaskGetSubTasksWithReadPermissionOnSub1() { // 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, "sub1", userId, READ); // when List<Task> subTasks = taskService.getSubTasks(parentTaskId); // then assertFalse(subTasks.isEmpty()); assertEquals(1, subTasks.size()); assertEquals("sub1", subTasks.get(0).getId()); deleteTask(parentTaskId, true); }
Example 20
Source File: TaskServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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) {} }