use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeCallActivityMappingIT method haveToPassAllVariablesCallActivityEmptyMappingNoTaskTest.
@Test
public void haveToPassAllVariablesCallActivityEmptyMappingNoTaskTest() {
securityUtil.logInAs("user");
// After the process has started, the subProcess task should be active
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PARENT_PROCESS_CALL_ACTIVITY_EMPTY_MAPPING_NO_TASK).build());
assertThat(processInstance).isNotNull();
ProcessInstance subProcessInstance = getSubProcess(processInstance);
assertThat(subProcessInstance.getProcessDefinitionKey()).isEqualTo(SUB_PROCESS_CALL_ACTIVITY);
Task task = getTask(subProcessInstance);
taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
List<VariableInstance> subProcVariables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(subProcessInstance.getId()).build());
assertThat(subProcVariables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("output_unmapped_variable_with_non_matching_connector_output_name", "default"), tuple("input_unmapped_variable_with_non_matching_connector_input_name", "inTest"), tuple("name", "inName"), tuple("age", 20), tuple("subprocess_input_var2", 2), tuple("subprocess_input_var3", 3), tuple("subprocess_out_var2", 222), tuple("subprocess_out_var1", "outValue"), tuple("subprocess_input_var1", "value1"), tuple("subprocess_static_value", "static some value"));
assertThat("my-task-call-activity").isEqualTo(task.getName());
Map<String, Object> variablesForTask = new HashMap<>();
variablesForTask.put("input_variable_name_1", "fromSubprocessName");
completeTask(task.getId(), variablesForTask);
List<VariableInstance> parentVariablesAfterComnplete = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(processInstance.getId()).build());
assertThat(parentVariablesAfterComnplete).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("output_unmapped_variable_with_non_matching_connector_output_name", "default"), tuple("input_unmapped_variable_with_non_matching_connector_input_name", "inTest"), tuple("name", "inName"), tuple("age", 20), tuple("subprocess_input_var2", 2), tuple("subprocess_input_var3", 3), tuple("subprocess_out_var2", 222), tuple("subprocess_out_var1", "outValue"), tuple("subprocess_input_var1", "value1"), tuple("subprocess_static_value", "static some value"), tuple("input_variable_name_1", "fromSubprocessName"));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeCallActivityMappingIT method haveToPassNoVariablesCallActivityEmptyMappingWithTaskTest.
@Test
public void haveToPassNoVariablesCallActivityEmptyMappingWithTaskTest() {
securityUtil.logInAs("user");
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PARENT_PROCESS_CALL_ACTIVITY_EMPTY_MAPPING_WITH_TASK).build());
assertThat(processInstance).isNotNull();
ProcessInstance subProcessInstance = getSubProcess(processInstance);
assertThat(subProcessInstance.getProcessDefinitionKey()).isEqualTo(SUB_PROCESS_CALL_ACTIVITY);
Task task = getTask(subProcessInstance);
taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
List<VariableInstance> subProcVariables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(subProcessInstance.getId()).build());
assertThat(subProcVariables).extracting(VariableInstance::getName, VariableInstance::getValue).size().isEqualTo(6);
assertThat(subProcVariables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("subprocess_input_var2", 2), tuple("subprocess_input_var3", 3), tuple("subprocess_out_var2", 222), tuple("subprocess_out_var1", "outValue"), tuple("subprocess_input_var1", "value1"), tuple("subprocess_static_value", "static some value"));
assertThat("my-task-call-activity").isEqualTo(task.getName());
Map<String, Object> variablesForTask = new HashMap<>();
variablesForTask.put("input_variable_name_1", "fromSubprocessName");
completeTask(task.getId(), variablesForTask);
List<VariableInstance> parentVariablesAfterComnplete = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(processInstance.getId()).build());
assertThat(parentVariablesAfterComnplete).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("output_unmapped_variable_with_non_matching_connector_output_name", "default"), tuple("input_unmapped_variable_with_non_matching_connector_input_name", "inTest"), tuple("name", "inName"), tuple("age", 20));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeVariableMappingTest method shouldMapVariables.
@Test
public void shouldMapVariables() {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(VARIABLE_MAPPING_PROCESS);
List<VariableInstance> variables = processBaseRuntime.getProcessVariablesByProcessId(processInstance.getId());
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("name", "outName"), tuple("age", 35), tuple("input_unmapped_variable_with_matching_name", "inTest"), tuple("input_unmapped_variable_with_non_matching_connector_input_name", "inTest"), tuple("nickName", "testName"), tuple("out_unmapped_variable_matching_name", "default"), tuple("output_unmapped_variable_with_non_matching_connector_output_name", "default"));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeVariableMappingTest method should_resolveExpression_when_expressionIsInInputMappingValueOrInMappedProperty.
@Test
public void should_resolveExpression_when_expressionIsInInputMappingValueOrInMappedProperty() {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(VARIABLE_MAPPING_EXPRESSION_PROCESS);
List<VariableInstance> variables = processBaseRuntime.getProcessVariablesByProcessId(processInstance.getId());
String[] array = { "first", "${name}", "${surname}", "last" };
List<String> list = asList(array);
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("age-in-months", "${age * 12}");
dataMap.put("full-name", "${name} ${surname}");
dataMap.put("demoString", "expressionResolved");
dataMap.put("list", list);
JsonNode data = mapper.convertValue(dataMap, JsonNode.class);
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("age", 30), tuple("name", "outName"), tuple("surname", "Doe"), tuple("data", data), tuple("user-msg", "Hello ${name.concat(' ').concat(surname)}, today is your ${age}th birthday! It means ${age * 365.25} days of life"), tuple("input-unmapped-variable-with-matching-name", "${surname}"), tuple("input-unmapped-variable-with-non-matching-connector-input-name", "inTestExpression"), tuple("variableToResolve", "${name}"), tuple("out-unmapped-variable-matching-name", "defaultExpression"), tuple("output-unmapped-variable-with-non-matching-connector-output-name", "defaultExpression"), tuple("resident", true));
}
Aggregations