Search in sources :

Example 16 with VariableInstance

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

Example 17 with VariableInstance

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

Example 18 with VariableInstance

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")));
}
Also used : Task(org.activiti.api.task.model.Task) 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 19 with VariableInstance

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

Example 20 with VariableInstance

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());
}
Also used : Task(org.activiti.api.task.model.Task) HashMap(java.util.HashMap) 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)

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