本文整理汇总了Java中org.camunda.bpm.engine.task.Task.setName方法的典型用法代码示例。如果您正苦于以下问题:Java Task.setName方法的具体用法?Java Task.setName怎么用?Java Task.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.camunda.bpm.engine.task.Task
的用法示例。
在下文中一共展示了Task.setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testStandaloneTaskVariable
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testStandaloneTaskVariable() {
Task task = taskService.newTask();
task.setName("gonzoTask");
taskService.saveTask(task);
String taskId = task.getId();
try {
taskService
.setVariable(taskId, "instrument", Variables.serializedObjectValue("trumpet").serializationDataFormat(Variables.SerializationDataFormats.JAVA).create());
fail("Exception is expected.");
} catch (ProcessEngineException ex) {
assertEquals("ENGINE-17007 Cannot set variable with name instrument. Java serialization format is prohibited", ex.getMessage());
} finally {
taskService.deleteTask(taskId, true);
}
}
示例2: testStandaloneTaskTransientVariable
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testStandaloneTaskTransientVariable() {
Task task = taskService.newTask();
task.setName("gonzoTask");
taskService.saveTask(task);
String taskId = task.getId();
try {
taskService
.setVariable(taskId, "instrument", Variables.serializedObjectValue("trumpet")
.serializationDataFormat(Variables.SerializationDataFormats.JAVA)
.setTransient(true)
.create());
fail("Exception is expected.");
} catch (ProcessEngineException ex) {
assertEquals("ENGINE-17007 Cannot set variable with name instrument. Java serialization format is prohibited", ex.getMessage());
} finally {
taskService.deleteTask(taskId, true);
}
}
示例3: testHistoricTaskInstanceUpdate
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Deployment
public void testHistoricTaskInstanceUpdate() {
runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest").getId();
Task task = taskService.createTaskQuery().singleResult();
// Update and save the task's fields before it is finished
task.setPriority(12345);
task.setDescription("Updated description");
task.setName("Updated name");
task.setAssignee("gonzo");
taskService.saveTask(task);
taskService.complete(task.getId());
assertEquals(1, historyService.createHistoricTaskInstanceQuery().count());
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
assertEquals("Updated name", historicTaskInstance.getName());
assertEquals("Updated description", historicTaskInstance.getDescription());
assertEquals("gonzo", historicTaskInstance.getAssignee());
assertEquals("task", historicTaskInstance.getTaskDefinitionKey());
}
示例4: testStandaloneTaskTransientVariable
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Test
public void testStandaloneTaskTransientVariable() throws IOException {
Task task = taskService.newTask();
task.setName("gonzoTask");
taskService.saveTask(task);
String taskId = task.getId();
try{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(new String("trumpet"));
String serializedObject = StringUtil.fromBytes(Base64.encodeBase64(baos.toByteArray()), engineRule.getProcessEngine());
taskService.setVariable(taskId, "instrument",
Variables.serializedObjectValue(serializedObject)
.objectTypeName(String.class.getName())
.serializationDataFormat(Variables.SerializationDataFormats.JAVA)
.setTransient(true)
);
assertEquals("trumpet", taskService.getVariable(taskId, "instrument"));
} finally {
taskService.deleteTask(taskId, true);
}
}
示例5: testSubTaskData
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@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"));
}
示例6: updateTask
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
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());
}
示例7: shouldReturnTasksWithTaskNameOrTaskDescription
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Test
public void shouldReturnTasksWithTaskNameOrTaskDescription() {
// given
Task task1 = taskService.newTask();
task1.setName("aTaskName");
taskService.saveTask(task1);
Task task2 = taskService.newTask();
task2.setDescription("aTaskDescription");
taskService.saveTask(task2);
// when
List<Task> tasks = taskService.createTaskQuery()
.or()
.taskName("aTaskName")
.taskDescription("aTaskDescription")
.endOr()
.list();
// then
assertEquals(2, tasks.size());
}
示例8: createTasks
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
protected void createTasks() {
Task task = taskService.newTask("task1");
task.setName("Task 1");
task.setOwner(testUser.getId());
task.setDelegationState(DelegationState.PENDING);
taskService.saveTask(task);
taskService.addCandidateGroup(task.getId(), "accounting");
task = taskService.newTask("task2");
task.setName("Task 2");
task.setOwner(testUser.getId());
task.setDelegationState(DelegationState.RESOLVED);
taskService.saveTask(task);
taskService.setAssignee(task.getId(), "kermit");
taskService.addCandidateGroup(task.getId(), "accounting");
task = taskService.newTask("task3");
task.setName("Task 3");
task.setOwner(testUser.getId());
task.setDelegationState(DelegationState.RESOLVED);
taskService.saveTask(task);
}
示例9: createTaskForTenant
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
protected void createTaskForTenant(String tenantId) {
Task newTask = taskService.newTask();
newTask.setName("testTask");
if(tenantId != null) {
newTask.setTenantId(tenantId);
}
taskService.saveTask(newTask);
taskIds.add(newTask.getId());
}
示例10: generateDummyTasks
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
private List<String> generateDummyTasks(int nrOfTasks) {
ArrayList<String> taskIds = new ArrayList<String>();
for (int i = 0; i < nrOfTasks; i++) {
Task task = taskService.newTask();
task.setName(((char) ('A' + i)) + "");
taskService.saveTask(task);
taskIds.add(task.getId());
}
return taskIds;
}
示例11: testStandaloneTaskVariables
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testStandaloneTaskVariables() {
Task task = taskService.newTask();
task.setName("gonzoTask");
taskService.saveTask(task);
String taskId = task.getId();
taskService.setVariable(taskId, "instrument", "trumpet");
assertEquals("trumpet", taskService.getVariable(taskId, "instrument"));
taskService.deleteTask(taskId, true);
}
示例12: shouldReturnTasksWithMultipleOrCriteria
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Test
public void shouldReturnTasksWithMultipleOrCriteria() {
// given
Task task1 = taskService.newTask();
task1.setName("aTaskName");
taskService.saveTask(task1);
Task task2 = taskService.newTask();
task2.setDescription("aTaskDescription");
taskService.saveTask(task2);
Task task3 = taskService.newTask();
taskService.saveTask(task3);
Task task4 = taskService.newTask();
task4.setPriority(5);
taskService.saveTask(task4);
Task task5 = taskService.newTask();
task5.setOwner("aTaskOwner");
taskService.saveTask(task5);
// when
List<Task> tasks = taskService.createTaskQuery()
.or()
.taskName("aTaskName")
.taskDescription("aTaskDescription")
.taskId(task3.getId())
.taskPriority(5)
.taskOwner("aTaskOwner")
.endOr()
.list();
// then
assertEquals(5, tasks.size());
}
示例13: testCreateToComplete
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testCreateToComplete() {
// Create and save task
Task task = taskService.newTask();
task.setName("testTask");
taskService.saveTask(task);
String taskId = task.getId();
// Add user as candidate user
taskService.addCandidateUser(taskId, "kermit");
taskService.addCandidateUser(taskId, "gonzo");
// Retrieve task list for jbarrez
List<Task> tasks = taskService.createTaskQuery().taskCandidateUser("kermit").list();
assertEquals(1, tasks.size());
assertEquals("testTask", tasks.get(0).getName());
// Retrieve task list for tbaeyens
tasks = taskService.createTaskQuery().taskCandidateUser("gonzo").list();
assertEquals(1, tasks.size());
assertEquals("testTask", tasks.get(0).getName());
// Claim task
taskService.claim(taskId, "kermit");
// Tasks shouldn't appear in the candidate tasklists anymore
assertTrue(taskService.createTaskQuery().taskCandidateUser("kermit").list().isEmpty());
assertTrue(taskService.createTaskQuery().taskCandidateUser("gonzo").list().isEmpty());
// Complete task
taskService.deleteTask(taskId, true);
// Task should be removed from runtime data
// TODO: check for historic data when implemented!
assertNull(taskService.createTaskQuery().taskId(taskId).singleResult());
}
示例14: testGetTaskFormVariables_StandaloneTask
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Test
public void testGetTaskFormVariables_StandaloneTask() {
Map<String, Object> processVars = new HashMap<String, Object>();
processVars.put("someString", "initialValue");
processVars.put("initialBooleanVariable", true);
processVars.put("initialLongVariable", 1l);
processVars.put("serializable", Arrays.asList("a", "b", "c"));
// create new standalone task
Task standaloneTask = taskService.newTask();
standaloneTask.setName("A Standalone Task");
taskService.saveTask(standaloneTask);
Task task = taskService.createTaskQuery().singleResult();
// set variables
taskService.setVariables(task.getId(), processVars);
VariableMap variables = formService.getTaskFormVariables(task.getId());
assertEquals(4, variables.size());
assertEquals("initialValue", variables.get("someString"));
assertEquals("initialValue", variables.getValueTyped("someString").getValue());
assertEquals(ValueType.STRING, variables.getValueTyped("someString").getType());
assertEquals(true, variables.get("initialBooleanVariable"));
assertEquals(true, variables.getValueTyped("initialBooleanVariable").getValue());
assertEquals(ValueType.BOOLEAN, variables.getValueTyped("initialBooleanVariable").getType());
assertEquals(1l, variables.get("initialLongVariable"));
assertEquals(1l, variables.getValueTyped("initialLongVariable").getValue());
assertEquals(ValueType.LONG, variables.getValueTyped("initialLongVariable").getType());
assertNotNull(variables.get("serializable"));
// override the long variable
taskService.setVariable(task.getId(), "initialLongVariable", 2l);
variables = formService.getTaskFormVariables(task.getId());
assertEquals(4, variables.size());
assertEquals(2l, variables.get("initialLongVariable"));
assertEquals(2l, variables.getValueTyped("initialLongVariable").getValue());
assertEquals(ValueType.LONG, variables.getValueTyped("initialLongVariable").getType());
// get restricted set of variables
variables = formService.getTaskFormVariables(task.getId(), Arrays.asList("someString"), true);
assertEquals(1, variables.size());
assertEquals("initialValue", variables.get("someString"));
assertEquals("initialValue", variables.getValueTyped("someString").getValue());
assertEquals(ValueType.STRING, variables.getValueTyped("someString").getType());
// request non-existing variable
variables = formService.getTaskFormVariables(task.getId(), Arrays.asList("non-existing!"), true);
assertEquals(0, variables.size());
// null => all
variables = formService.getTaskFormVariables(task.getId(), null, true);
assertEquals(4, variables.size());
// Finally, delete task
taskService.deleteTask(task.getId(), true);
}
示例15: testSubTask
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testSubTask() {
Task gonzoTask = taskService.newTask();
gonzoTask.setName("gonzoTask");
taskService.saveTask(gonzoTask);
Task subTaskOne = taskService.newTask();
subTaskOne.setName("subtask one");
String gonzoTaskId = gonzoTask.getId();
subTaskOne.setParentTaskId(gonzoTaskId);
taskService.saveTask(subTaskOne);
Task subTaskTwo = taskService.newTask();
subTaskTwo.setName("subtask two");
subTaskTwo.setParentTaskId(gonzoTaskId);
taskService.saveTask(subTaskTwo);
String subTaskId = subTaskOne.getId();
assertTrue(taskService.getSubTasks(subTaskId).isEmpty());
assertTrue(historyService
.createHistoricTaskInstanceQuery()
.taskParentTaskId(subTaskId)
.list()
.isEmpty());
List<Task> subTasks = taskService.getSubTasks(gonzoTaskId);
Set<String> subTaskNames = new HashSet<String>();
for (Task subTask: subTasks) {
subTaskNames.add(subTask.getName());
}
if(processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_AUDIT.getId()) {
Set<String> expectedSubTaskNames = new HashSet<String>();
expectedSubTaskNames.add("subtask one");
expectedSubTaskNames.add("subtask two");
assertEquals(expectedSubTaskNames, subTaskNames);
List<HistoricTaskInstance> historicSubTasks = historyService
.createHistoricTaskInstanceQuery()
.taskParentTaskId(gonzoTaskId)
.list();
subTaskNames = new HashSet<String>();
for (HistoricTaskInstance historicSubTask: historicSubTasks) {
subTaskNames.add(historicSubTask.getName());
}
assertEquals(expectedSubTaskNames, subTaskNames);
}
taskService.deleteTask(gonzoTaskId, true);
}