本文整理了Java中org.camunda.bpm.engine.task.Task
类的一些代码示例,展示了Task
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task
类的具体详情如下:
包路径:org.camunda.bpm.engine.task.Task
类名称:Task
[英]Represents one task for a human user.
[中]表示人工用户的一个任务。
代码示例来源:origin: camunda/camunda-bpm-platform
public static TaskDto fromEntity(Task task) {
TaskDto dto = new TaskDto();
dto.id = task.getId();
dto.name = task.getName();
dto.assignee = task.getAssignee();
dto.created = task.getCreateTime();
dto.due = task.getDueDate();
dto.followUp = task.getFollowUpDate();
if (task.getDelegationState() != null) {
dto.delegationState = task.getDelegationState().toString();
dto.description = task.getDescription();
dto.executionId = task.getExecutionId();
dto.owner = task.getOwner();
dto.parentTaskId = task.getParentTaskId();
dto.priority = task.getPriority();
dto.processDefinitionId = task.getProcessDefinitionId();
dto.processInstanceId = task.getProcessInstanceId();
dto.taskDefinitionKey = task.getTaskDefinitionKey();
dto.caseDefinitionId = task.getCaseDefinitionId();
dto.caseExecutionId = task.getCaseExecutionId();
dto.caseInstanceId = task.getCaseInstanceId();
dto.suspended = task.isSuspended();
dto.tenantId = task.getTenantId();
dto.formKey = task.getFormKey();
代码示例来源:origin: camunda/camunda-bpm-platform
public void tesBasicTaskPropertiesNotNull() {
Task task = taskService.createTaskQuery().taskId(taskIds.get(0)).singleResult();
assertNotNull(task.getDescription());
assertNotNull(task.getId());
assertNotNull(task.getName());
assertNotNull(task.getCreateTime());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testDeleteAssignee() {
Task task = taskService.newTask();
task.setAssignee("nonExistingUser");
taskService.saveTask(task);
taskService.deleteUserIdentityLink(task.getId(), "nonExistingUser", IdentityLinkType.ASSIGNEE);
task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
assertNull(task.getAssignee());
assertEquals(0, taskService.getIdentityLinksForTask(task.getId()).size());
// cleanup
taskService.deleteTask(task.getId(), true);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment
public void testParallelUserTasksCustomExtensions() {
Map<String, Object> vars = new HashMap<String, Object>();
List<String> assigneeList = Arrays.asList("kermit", "gonzo", "fozzie");
vars.put("assigneeList", assigneeList);
runtimeService.startProcessInstanceByKey("miSequentialUserTasks", vars);
for (String assignee : assigneeList) {
Task task = taskService.createTaskQuery().singleResult();
assertEquals(assignee, task.getAssignee());
taskService.complete(task.getId());
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
task.setDescription("description");
task.setName("taskname");
task.setPriority(0);
task.setAssignee("taskassignee");
task.setOwner("taskowner");
Date dueDate = sdf.parse("01/02/2003 04:05:06");
task.setDueDate(dueDate);
task.setCaseInstanceId("taskcaseinstanceid");
taskService.saveTask(task);
task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
assertEquals("description", task.getDescription());
assertEquals("taskname", task.getName());
assertEquals("taskassignee", task.getAssignee());
assertEquals("taskowner", task.getOwner());
assertEquals(dueDate, task.getDueDate());
assertEquals(0, task.getPriority());
assertEquals("taskcaseinstanceid", task.getCaseInstanceId());
.taskId(task.getId())
.singleResult();
assertEquals("taskname", historicTaskInstance.getName());
task.setName("updatedtaskname");
task.setDescription("updateddescription");
task.setPriority(1);
task.setAssignee("updatedassignee");
task.setOwner("updatedowner");
dueDate = sdf.parse("01/02/2003 04:05:06");
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment
public void testTaskPropertiesNotNull() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
List<String> activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getId());
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task.getId());
assertEquals("my task", task.getName());
assertEquals("Very important", task.getDescription());
assertTrue(task.getPriority() > 0);
assertEquals("kermit", task.getAssignee());
assertEquals(processInstance.getId(), task.getProcessInstanceId());
assertEquals(processInstance.getId(), task.getExecutionId());
assertNotNull(task.getProcessDefinitionId());
assertNotNull(task.getTaskDefinitionKey());
assertNotNull(task.getCreateTime());
// the next test verifies that if an execution creates a task, that no events are created during creation of the task.
if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
assertEquals(0, taskService.getTaskEvents(task.getId()).size());
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment( resources = {
"org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownBySequentialAbstractBpmnActivityBehavior.bpmn20.xml"
})
public void testCatchExceptionThrownByExecuteOfSequentialAbstractBpmnActivityBehavior() {
String pi = runtimeService.startProcessInstanceByKey("testProcess", throwException()).getId();
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertNull(runtimeService.getVariable(pi, "signaled"));
Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
assertNotNull(userTask);
assertEquals("userTaskException", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testOutputAll.cmmn",
"org/camunda/bpm/engine/test/cmmn/processtask/subProcessWithError.bpmn"})
public void testOutputWhenErrorOccurs() {
String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE).getId();
Task task = queryTask();
assertThat(task.getName(), is("SubTask"));
String variableName = "foo";
Object variableValue = "bar";
runtimeService.setVariable(task.getProcessInstanceId(), variableName, variableValue);
taskService.complete(task.getId());
Object variable = caseService.getVariable(caseInstanceId, variableName);
assertThat(variable, is(notNullValue()));
assertThat(variable, is(variableValue));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment
public void testCatchErrorOnEmbeddedSubprocess() {
runtimeService.startProcessInstanceByKey("boundaryErrorOnEmbeddedSubprocess");
// After process start, usertask in subprocess should exist
Task task = taskService.createTaskQuery().singleResult();
assertEquals("subprocessTask", task.getName());
// After task completion, error end event is reached and caught
taskService.complete(task.getId());
task = taskService.createTaskQuery().singleResult();
assertEquals("task after catching the error", task.getName());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testUserTaskMigrationInSubProcessScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId())
.mapEqualActivities()
.build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
// the entities were migrated
testHelper.assertExecutionTreeAfterMigration()
.hasProcessDefinitionId(targetProcessDefinition.getId())
.matches(
describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId())
.child("userTask").scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("userTask"))
.done());
Task task = testHelper.snapshotBeforeMigration.getTaskForKey("userTask");
Task migratedTask = testHelper.snapshotAfterMigration.getTaskForKey("userTask");
Assert.assertEquals(task.getId(), migratedTask.getId());
Assert.assertEquals(targetProcessDefinition.getId(), migratedTask.getProcessDefinitionId());
// and it is possible to successfully complete the migrated instance
rule.getTaskService().complete(migratedTask.getId());
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment
public void testTaskAssignee() {
// Start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("taskAssigneeExampleProcess");
// Get task list
List<Task> tasks = taskService
.createTaskQuery()
.taskAssignee("kermit")
.list();
assertEquals(1, tasks.size());
Task myTask = tasks.get(0);
assertEquals("Schedule meeting", myTask.getName());
assertEquals("Schedule an engineering meeting for next week with the new hire.", myTask.getDescription());
// Complete task. Process is now finished
taskService.complete(myTask.getId());
// assert if the process instance completed
assertProcessEnded(processInstance.getId());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testMigrateWithSubTask() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId())
.mapEqualActivities()
.build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
Task task = rule.getTaskService().createTaskQuery().singleResult();
Task subTask = rule.getTaskService().newTask();
subTask.setParentTaskId(task.getId());
rule.getTaskService().saveTask(subTask);
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then the sub task properties have not been updated (i.e. subtask should not reference the process instance/definition now)
Task subTaskAfterMigration = rule.getTaskService().createTaskQuery().taskId(subTask.getId()).singleResult();
Assert.assertNull(subTaskAfterMigration.getProcessDefinitionId());
Assert.assertNull(subTaskAfterMigration.getProcessInstanceId());
Assert.assertNull(subTaskAfterMigration.getTaskDefinitionKey());
// the tasks can be completed and the process can be ended
rule.getTaskService().complete(subTask.getId());
rule.getTaskService().complete(task.getId());
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
if (!rule.getProcessEngineConfiguration().getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_NONE)) {
rule.getHistoryService().deleteHistoricTaskInstance(subTaskAfterMigration.getId());
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/escalation/EscalationEventTest.throwEscalationEvent.bpmn20.xml",
"org/camunda/bpm/engine/test/bpmn/event/escalation/EscalationEventTest.testPropagateOutputVariablesWhileCatchEscalationOnCallActivity.bpmn20.xml"})
public void testPropagateOutputVariablesTwoTimes() {
Map<String,Object> variables = new HashMap<String, Object>();
variables.put("input", 42);
String processInstanceId = runtimeService.startProcessInstanceByKey("catchEscalationProcess", variables).getId();
// when throw an escalation event on called process
Task taskInSuperProcess = taskService.createTaskQuery().taskDefinitionKey("taskAfterCatchedEscalation").singleResult();
assertNotNull(taskInSuperProcess);
// (1) the variables has been passed for the first time (from sub process to super process)
assertEquals(42, runtimeService.getVariable(processInstanceId, "output"));
// change variable "input" in sub process
Task taskInSubProcess = taskService.createTaskQuery().taskDefinitionKey("task").singleResult();
runtimeService.setVariable(taskInSubProcess.getProcessInstanceId(), "input", 999);
taskService.complete(taskInSubProcess.getId());
// (2) the variables has been passed for the second time (from sub process to super process)
assertEquals(999, runtimeService.getVariable(processInstanceId, "output"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = "org/camunda/bpm/engine/test/api/form/FormsProcess.bpmn20.xml")
@Test
public void testGetTaskFormKey() {
String processDefinitionId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
runtimeService.startProcessInstanceById(processDefinitionId);
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
String expectedFormKey = formService.getTaskFormData(task.getId()).getFormKey();
String actualFormKey = formService.getTaskFormKey(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
assertEquals(expectedFormKey, actualFormKey);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public String getProperty(Task obj) {
return obj.getName();
}
});
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetTaskFormKeyWithDisabledTenantCheck() {
testRule.deployForTenant(TENANT_ONE,
"org/camunda/bpm/engine/test/api/authorization/formKeyProcess.bpmn20.xml");
runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
Task task = taskService.createTaskQuery().singleResult();
identityService.setAuthentication("aUserId", null);
processEngineConfiguration.setTenantCheckEnabled(false);
formService.getTaskFormKey(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
// then
assertEquals("aTaskFormKey", formService.getTaskFormKey(task.getProcessDefinitionId(), task.getTaskDefinitionKey()));
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testSignalEventReceivedWithUpdateInstancesPermissionOnProcessDefinition() {
// given
startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY);
createGrantAuthorization(PROCESS_DEFINITION, SIGNAL_BOUNDARY_PROCESS_KEY, userId, UPDATE_INSTANCE);
// when
runtimeService.signalEventReceived("alert");
// then
Task task = selectSingleTask();
assertNotNull(task);
assertEquals("taskAfterBoundaryEvent", task.getTaskDefinitionKey());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public String getProperty(Task obj) {
return obj.getProcessInstanceId();
}
});
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public Date getProperty(Task obj) {
return obj.getDueDate();
}
});
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/tasklistener/TaskListenerTest.bpmn20.xml"})
public void testTaskCreateListener() {
runtimeService.startProcessInstanceByKey("taskListenerProcess");
Task task = taskService.createTaskQuery().singleResult();
assertEquals("Schedule meeting", task.getName());
assertEquals("TaskCreateListener is listening!", task.getDescription());
}
内容来源于网络,如有侵权,请联系作者删除!