use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class TaskVariablesTest method shouldGetTaskIdAndProcessInstanceId.
@Test
public void shouldGetTaskIdAndProcessInstanceId() {
securityUtil.logInAs("user1");
startProcess();
createVariables();
VariableInstance variableOneRuntime = variableInstanceList.get(0);
assertThat(variableOneRuntime.getTaskId()).isEqualTo(taskId);
assertThat(variableOneRuntime.getProcessInstanceId()).isEqualTo(processInstanceId);
assertThat(RuntimeTestConfiguration.collectedEvents).extracting("eventType", "entity.name", "entity.value").containsExactly(tuple(VariableEvent.VariableEvents.VARIABLE_CREATED, variableInstanceList.get(0).getName(), variableInstanceList.get(0).getValue()), tuple(VariableEvent.VariableEvents.VARIABLE_CREATED, variableInstanceList.get(1).getName(), variableInstanceList.get(1).getValue()));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class TaskVariablesTest method shouldGetRightVariableType.
@Test
public void shouldGetRightVariableType() {
securityUtil.logInAs("user1");
startProcess();
createVariables();
VariableInstance variableOneRuntime = variableInstanceList.get(0);
VariableInstance variableTwoRuntime = variableInstanceList.get(1);
assertThat(variableOneRuntime.getType()).isEqualTo("string");
assertThat(variableTwoRuntime.getType()).isEqualTo("integer");
assertThat(RuntimeTestConfiguration.collectedEvents).extracting("eventType", "entity.name", "entity.value").containsExactly(tuple(VariableEvent.VariableEvents.VARIABLE_CREATED, variableInstanceList.get(0).getName(), variableInstanceList.get(0).getValue()), tuple(VariableEvent.VariableEvents.VARIABLE_CREATED, variableInstanceList.get(1).getName(), variableInstanceList.get(1).getValue()));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class TaskRuntimeMultiInstanceIT method parallelMultiInstance_should_collectOutputValues.
@Test
public void parallelMultiInstance_should_collectOutputValues() {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelUserTasksOutputCollection");
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).hasSize(2);
taskBaseRuntime.completeTask(tasks.get(0), singletonMap("meal", "pizza"));
taskBaseRuntime.completeTask(tasks.get(1), singletonMap("meal", "pasta"));
List<VariableInstance> variables = processBaseRuntime.getVariables(processInstance);
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).contains(tuple("meals", asList("pizza", "pasta")));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class TaskRuntimeVariableMappingIT method processTaskVarMapping.
@Test
public void processTaskVarMapping() {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(TASK_VAR_MAPPING);
Date date = dateFormatterProvider.parse("2019-09-01");
Date datetime = dateFormatterProvider.parse("2019-09-01T10:20:30.000Z");
Task task = checkTasks(processInstance.getId());
assertThat(task.getName()).isEqualTo("testSimpleTask");
List<VariableInstance> procVariables = processBaseRuntime.getProcessVariablesByProcessId(processInstance.getId());
assertThat(procVariables).isNotNull().extracting(VariableInstance::getName, VariableInstance::getType, VariableInstance::getValue).containsOnly(tuple("process_variable_unmapped_1", "string", "unmapped1Value"), tuple("process_variable_inputmap_1", "string", "inputmap1Value"), tuple("process_variable_outputmap_1", "string", "outputmap1Value"), tuple("process-variable-date", "date", date), tuple("process-variable-datetime", "date", datetime));
List<VariableInstance> taskVariables = taskBaseRuntime.getTasksVariablesByTaskId(task.getId());
assertThat(taskVariables).isNotNull().extracting(VariableInstance::getName, VariableInstance::getType, VariableInstance::getValue).containsOnly(tuple("task_input_variable_name_1", "string", "inputmap1Value"), tuple("task-variable-date", "date", date), tuple("task-variable-datetime", "date", datetime));
Map<String, Object> variables = new HashMap<>();
variables.put("task_input_variable_name_1", // This should not be set to 'process_variable_inputmap_1'
"outputValue");
variables.put("task_output_variable_name_1", // This should be set to 'process_variable_outputmap_1'
"outputTaskValue");
taskBaseRuntime.completeTask(task.getId(), variables);
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", "outputTaskValue"), tuple("process-variable-date", date), tuple("process-variable-datetime", datetime));
processBaseRuntime.delete(processInstance.getId());
}
use of org.activiti.api.model.shared.model.VariableInstance 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());
}
Aggregations