use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeConnectorIT method shouldSupportStaticValuesForConnectorInputsEvenWhenThereIsNoConnectorDefinition.
@Test
public void shouldSupportStaticValuesForConnectorInputsEvenWhenThereIsNoConnectorDefinition() {
// given
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey("processWithExtensionsButNoConnectorDef").build());
// when
List<VariableInstance> variables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(processInstance).build());
// then
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("age", // default value incremented by one by the connector
21), tuple("name", // static value passed to the connector ans send back as part of integration result
"Paul"));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeMultipleInstancesIT method should_executeMultipleInstances.
@Test
public void should_executeMultipleInstances() {
securityUtil.logInAs("user");
ProcessInstance processInstance1 = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PROCESS_MULTIPLE_INSTANCE_1).build());
assertThat(processInstance1).isNotNull();
List<VariableInstance> processInstance1Vars = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(processInstance1.getId()).build());
assertThat(processInstance1Vars).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("name", "Kermit"));
ProcessInstance processInstance2 = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PROCESS_MULTIPLE_INSTANCE_2).build());
assertThat(processInstance1).isNotNull();
List<VariableInstance> processInstance2Vars = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(processInstance2.getId()).build());
assertThat(processInstance2Vars).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("lastName", "The Frog"));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessExtensionsIT method processInstanceHasValidInitialVariables.
@Test
public void processInstanceHasValidInitialVariables() throws ParseException {
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).withVariable("name", "bob").withVariable("subscribe", true).withVariable("birth", new SimpleDateFormat("yyyy-MM-dd").parse("2009-11-30")).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(5);
assertThat(variableInstances).extracting("name").contains("extraVar", "name", "age", "birth", "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_createAndStartProcessAreCalled.
@Test
public void should_mapProcessVariables_when_createAndStartProcessAreCalled() {
// given
ProcessInstance createdProcess = processRuntime.create(ProcessPayloadBuilder.create().withProcessDefinitionKey("process-b42a166d-605b-4eec-8b96-82b1253666bf").withName("TEST").build());
ProcessInstance startedProcess = processRuntime.startCreatedProcess(createdProcess.getId(), ProcessPayloadBuilder.start().withProcessDefinitionKey("process-b42a166d-605b-4eec-8b96-82b1253666bf").withVariable("Text0xfems", "name_value").withVariable("Text0rvs0o", "email_value").withBusinessKey("my business key").build());
// then
List<VariableInstance> variableInstances = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(startedProcess).build());
assertThat(variableInstances).isNotNull().hasSize(2).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("name", "name_value"), tuple("email", "email_value"));
// when
List<VariableInstance> taskVariables = retrieveVariablesForFirstTaskOfProcess(createdProcess);
// then
assertThat(taskVariables).isNotNull().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 ProcessRuntimeBPMNTimerIT method shouldExecuteProcessWithTimerStartExtension.
@Test
public void shouldExecuteProcessWithTimerStartExtension() {
securityUtil.logInAs("user");
Date startTime = new Date();
// when
Page<ProcessInstance> processInstances = processBaseRuntime.getProcessInstancesPage();
// then
assertThat(processInstances).isNotNull();
assertThat(processInstances.getContent()).isEmpty();
// when shift 31 minutes
long waitTime = 31 * 60 * 1000;
processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + waitTime));
// then
await().untilAsserted(() -> {
securityUtil.logInAs("user");
Page<ProcessInstance> processInstancePage = processBaseRuntime.getProcessInstancesPage();
// then
assertThat(processInstancePage).isNotNull();
assertThat(processInstancePage.getContent()).isNotEmpty();
ProcessInstance processInstance = processInstancePage.getContent().get(0);
assertThat(processInstance.getProcessDefinitionKey()).isEqualTo(VARIABLE_MAPPING_PROCESS_START_TIME);
List<VariableInstance> variables = processBaseRuntime.getProcessVariablesByProcessId(processInstance.getId());
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("process_variable_name", "value"));
});
}
Aggregations