use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessExtensionsIT method processInstanceHasInitialVariables.
@Test
public void processInstanceHasInitialVariables() {
ProcessRuntimeConfiguration configuration = processRuntime.configuration();
assertThat(configuration).isNotNull();
// start a process with vars then check default and specified vars exist
ProcessInstance initialVarsProcess = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(INITIAL_VARS_PROCESS).withVariable("extraVar", true).withVariable("age", 10).withBusinessKey("my business key").build());
assertThat(initialVarsProcess).isNotNull();
assertThat(initialVarsProcess.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
List<VariableInstance> variableInstances = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(initialVarsProcess).build());
assertThat(variableInstances).isNotNull();
assertThat(variableInstances).hasSize(4);
assertThat(variableInstances).extracting("name").contains("extraVar", "name", "age", "birth").doesNotContain("subscribe");
// cleanup
processRuntime.delete(ProcessPayloadBuilder.delete(initialVarsProcess));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessExtensionsIT method should_mapProcessVariables_when_startEventMappingExists.
@Test
public void should_mapProcessVariables_when_startEventMappingExists() {
// given
ProcessInstance process = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey("process-b42a166d-605b-4eec-8b96-82b1253666bf").withVariable("Text0xfems", "name_value").withVariable("Text0rvs0o", "email_value").withBusinessKey("my business key").build());
// when
List<VariableInstance> variableInstances = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(process).build());
// then
assertThat(variableInstances).isNotNull().hasSize(2).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("name", "name_value"), tuple("email", "email_value"));
// when
List<VariableInstance> taskVariables = retrieveVariablesForFirstTaskOfProcess(process);
// then
assertThat(taskVariables).isNotNull().hasSize(2).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("nameInTask", "name_value"), tuple("emailInTask", "email_value"));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeVariableMappingTest method should_resolveExpression_when_expressionIsInOutputMappingValueOrInMappedProperty.
@Test
public void should_resolveExpression_when_expressionIsInOutputMappingValueOrInMappedProperty() {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(OUTPUT_MAPPING_EXPRESSION_VALUE_PROCESS);
List<VariableInstance> variables = processBaseRuntime.getProcessVariablesByProcessId(processInstance.getId());
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("name", "John"), tuple("outVar", "Resolved expression: value-set-in-connector"), tuple("outVarFromJsonExpression", "Tower of London"));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessVariablesTest method shouldNotBeTaskVariable.
@Test
public void shouldNotBeTaskVariable() {
securityUtil.logInAs("user1");
startProcess();
setVariables();
VariableInstance variableOneRuntime = variableInstanceList.get(0);
assertThat(variableOneRuntime.isTaskVariable()).isFalse();
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 ProcessVariablesTest method shouldGetProcessIdAndNotTaskId.
@Test
public void shouldGetProcessIdAndNotTaskId() {
securityUtil.logInAs("user1");
startProcess();
setVariables();
VariableInstance variableOneRuntime = variableInstanceList.get(0);
assertThat(variableOneRuntime.getProcessInstanceId()).isEqualTo(processInstanceId);
assertThat(variableOneRuntime.getTaskId()).isNull();
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()));
}
Aggregations