use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeVariableMappingIT method allVariablesShouldBePassedWhenThereIsNoMapping.
@Test
public void allVariablesShouldBePassedWhenThereIsNoMapping() {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(TASK_VAR_NO_MAPPING);
Task task = checkTasks(processInstance.getId());
assertThat(task.getName()).isEqualTo("testSimpleTask");
List<VariableInstance> procVariables = processBaseRuntime.getProcessVariablesByProcessId(processInstance.getId());
assertThat(procVariables).isNotNull().extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("process_variable_unmapped_1", "unmapped1Value"), tuple("process_variable_inputmap_1", "inputmap1Value"), tuple("process_variable_outputmap_1", "outputmap1Value"));
List<VariableInstance> taskVariables = taskBaseRuntime.getTasksVariablesByTaskId(task.getId());
assertThat(taskVariables).isNotNull().extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("process_variable_unmapped_1", "unmapped1Value"), tuple("process_variable_inputmap_1", "inputmap1Value"), tuple("process_variable_outputmap_1", "outputmap1Value"));
Map<String, Object> variables = new HashMap<>();
variables.put("task_input_variable_name_1", "outputValue");
variables.put("task_output_variable_name_1", "outputTaskValue");
taskBaseRuntime.completeTask(task.getId(), variables);
procVariables = processBaseRuntime.getProcessVariablesByProcessId(processInstance.getId());
assertThat(procVariables).isNotNull().extracting(VariableInstance::getName, VariableInstance::getValue).containsExactlyInAnyOrder(tuple("process_variable_unmapped_1", "unmapped1Value"), tuple("process_variable_inputmap_1", "inputmap1Value"), tuple("process_variable_outputmap_1", "outputmap1Value"), tuple("task_input_variable_name_1", "outputValue"), tuple("task_output_variable_name_1", "outputTaskValue"));
processBaseRuntime.delete(processInstance.getId());
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeVariableMappingIT method taskShouldHaveNoVariablesWhenMappingIsEmpty.
@Test
public void taskShouldHaveNoVariablesWhenMappingIsEmpty() {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(TASK_EMPTY_VAR_MAPPING);
List<Task> tasks = taskBaseRuntime.getTasksByProcessInstanceId(processInstance.getId());
assertThat(tasks).isNotEmpty();
assertThat(tasks).hasSize(1);
Task task = tasks.get(0);
assertThat(task.getName()).isEqualTo("testSimpleTask");
List<VariableInstance> procVariables = processBaseRuntime.getProcessVariablesByProcessId(processInstance.getId());
assertThat(procVariables).isNotNull().extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("process_variable_unmapped_1", "unmapped1Value"), tuple("process_variable_inputmap_1", "inputmap1Value"), tuple("process_variable_outputmap_1", "outputmap1Value"));
List<VariableInstance> taskVariables = taskBaseRuntime.getTasksVariablesByTaskId(task.getId());
assertThat(taskVariables).isEmpty();
Map<String, Object> variables = new HashMap<>();
variables.put("task_input_variable_name_1", "outputValue");
variables.put("task_output_variable_name_1", "outputTaskValue");
taskBaseRuntime.completeTask(task.getId(), variables);
assertThat(procVariables).isNotNull().extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("process_variable_unmapped_1", "unmapped1Value"), tuple("process_variable_inputmap_1", "inputmap1Value"), tuple("process_variable_outputmap_1", "outputmap1Value"));
processBaseRuntime.delete(processInstance.getId());
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeTaskAssigneeTest method createStandaloneTaskForGroupAndAdminAssignUser.
@Test
public void createStandaloneTaskForGroupAndAdminAssignUser() {
securityUtil.logInAs("garth");
taskRuntime.create(TaskPayloadBuilder.create().withName("group task").withCandidateGroup("doctor").build());
// the owner should be able to see the created task
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getContent()).hasSize(1);
Task task = tasks.getContent().get(0);
assertThat(task.getAssignee()).isNull();
assertThat(task.getStatus()).isEqualTo(Task.TaskStatus.CREATED);
securityUtil.logInAs("admin");
Task assignedTask = taskAdminRuntime.assign(TaskPayloadBuilder.assign().withTaskId(task.getId()).withAssignee("garth").build());
assertThat(assignedTask.getAssignee()).isEqualTo("garth");
assertThat(assignedTask.getStatus()).isEqualTo(Task.TaskStatus.ASSIGNED);
securityUtil.logInAs("garth");
tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getContent()).hasSize(1);
task = tasks.getContent().get(0);
assertThat(task.getAssignee()).isEqualTo("garth");
taskRuntime.delete(TaskPayloadBuilder.delete().withTaskId(task.getId()).withReason("test clean up").build());
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeTaskAssigneeTest method createStandaloneTaskForUsersAndAdminReassignUser.
@Test
public void createStandaloneTaskForUsersAndAdminReassignUser() {
securityUtil.logInAs("garth");
taskRuntime.create(TaskPayloadBuilder.create().withName("group task").withCandidateUsers("dean").withCandidateUsers("garth").build());
// the owner should be able to see the created task
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getContent()).hasSize(1);
Task task = tasks.getContent().get(0);
assertThat(task.getAssignee()).isNull();
assertThat(task.getStatus()).isEqualTo(Task.TaskStatus.CREATED);
// Check that admin may assign a user to the task without assignee
securityUtil.logInAs("admin");
Task assignedTask = taskAdminRuntime.assign(TaskPayloadBuilder.assign().withTaskId(task.getId()).withAssignee("garth").build());
assertThat(assignedTask.getAssignee()).isEqualTo("garth");
assertThat(assignedTask.getStatus()).isEqualTo(Task.TaskStatus.ASSIGNED);
// Check that admin may reassign a user to the task when assignee is present
assignedTask = taskAdminRuntime.assign(TaskPayloadBuilder.assign().withTaskId(task.getId()).withAssignee("dean").build());
assertThat(assignedTask.getAssignee()).isEqualTo("dean");
assertThat(assignedTask.getStatus()).isEqualTo(Task.TaskStatus.ASSIGNED);
securityUtil.logInAs("dean");
tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getContent()).hasSize(1);
task = tasks.getContent().get(0);
assertThat(task.getAssignee()).isEqualTo("dean");
taskRuntime.delete(TaskPayloadBuilder.delete().withTaskId(task.getId()).withReason("test clean up").build());
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeTaskAssigneeTest method createStandaloneTaskForGroupAndClaim.
@Test
public void createStandaloneTaskForGroupAndClaim() {
securityUtil.logInAs("garth");
Task standAloneTask = taskRuntime.create(TaskPayloadBuilder.create().withName("group task").withCandidateGroup("doctor").build());
// the owner should be able to see the created task
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getContent()).hasSize(1);
Task task = tasks.getContent().get(0);
assertThat(task.getAssignee()).isNull();
assertThat(task.getStatus()).isEqualTo(Task.TaskStatus.CREATED);
Task claimedTask = taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
assertThat(claimedTask.getAssignee()).isEqualTo("garth");
assertThat(claimedTask.getStatus()).isEqualTo(Task.TaskStatus.ASSIGNED);
}
Aggregations