Search in sources :

Example 11 with VariableInstance

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));
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) ProcessRuntimeConfiguration(org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with VariableInstance

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"));
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with VariableInstance

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"));
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with VariableInstance

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()));
}
Also used : VariableInstance(org.activiti.api.model.shared.model.VariableInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with VariableInstance

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()));
}
Also used : VariableInstance(org.activiti.api.model.shared.model.VariableInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

VariableInstance (org.activiti.api.model.shared.model.VariableInstance)34 Test (org.junit.jupiter.api.Test)33 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)33 ProcessInstance (org.activiti.api.process.model.ProcessInstance)26 Task (org.activiti.api.task.model.Task)15 HashMap (java.util.HashMap)9 ArrayList (java.util.ArrayList)3 Collections.singletonMap (java.util.Collections.singletonMap)3 List (java.util.List)3 RuntimeEvent (org.activiti.api.model.shared.event.RuntimeEvent)3 StartMessageDeploymentDefinition (org.activiti.api.process.model.StartMessageDeploymentDefinition)3 StartMessageSubscription (org.activiti.api.process.model.StartMessageSubscription)3 MessagePayloadBuilder (org.activiti.api.process.model.builders.MessagePayloadBuilder)3 ProcessPayloadBuilder (org.activiti.api.process.model.builders.ProcessPayloadBuilder)3 BPMNMessageEvent (org.activiti.api.process.model.events.BPMNMessageEvent)3 MessageSubscriptionCancelledEvent (org.activiti.api.process.model.events.MessageSubscriptionCancelledEvent)3 MessageSubscriptionEvent (org.activiti.api.process.model.events.MessageSubscriptionEvent)3 ProcessRuntimeEvent (org.activiti.api.process.model.events.ProcessRuntimeEvent)3 StartMessageDeployedEvent (org.activiti.api.process.model.events.StartMessageDeployedEvent)3 ProcessRuntime (org.activiti.api.process.runtime.ProcessRuntime)3