use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class TaskVariablesTest method shouldBeTaskVariable.
@Test
public void shouldBeTaskVariable() {
securityUtil.logInAs("user1");
startProcess();
createVariables();
VariableInstance variableOneRuntime = variableInstanceList.get(0);
assertThat(variableOneRuntime.isTaskVariable()).isTrue();
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 ProcessRuntimeCallActivityMappingIT method basicCallActivityMappingTest.
@Test
public void basicCallActivityMappingTest() {
securityUtil.logInAs("user");
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PARENT_PROCESS_CALL_ACTIVITY).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("subprocess_input_var1", "inName"), tuple("subprocess_input_var2", 20), tuple("subprocess_input_var3", 5), tuple("input_static_value", "a static value"), tuple("subprocess_out_var1", "outValue"), tuple("subprocess_out_var2", 222), tuple("subprocess_static_value", "static some value"), tuple("var_not_exist_in_subprocess_extension_file", 20));
assertThat("my-task-call-activity").isEqualTo(task.getName());
Map<String, Object> variablesForTask = new HashMap<>();
variablesForTask.put("input_variable_name_1", "fromSubprocessName");
variablesForTask.put("input_variable_name_2", 39);
variablesForTask.put("out_variable_name_1", 176);
completeTask(task.getId(), variablesForTask);
List<VariableInstance> parentVariables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(processInstance.getId()).build());
assertThat(parentVariables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("name", "outValue"), tuple("age", 222), tuple("output_unmapped_variable_with_non_matching_connector_output_name", "default"), tuple("input_unmapped_variable_with_non_matching_connector_input_name", "inTest"));
cleanUp();
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeBPMNMessageIT method shouldStartProcessByMessageWithMappedPayload.
@Test
public void shouldStartProcessByMessageWithMappedPayload() {
// when
ProcessInstance process = processRuntime.start(MessagePayloadBuilder.start(START_MESSAGE_PAYLOAD).withBusinessKey("businessKey").withVariable("message_variable_name", "value").build());
// then
assertThat(MessageTestConfiguration.messageEvents).isNotEmpty().extracting(BPMNMessageEvent::getEventType, BPMNMessageEvent::getProcessDefinitionId, BPMNMessageEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getMessagePayload().getName(), event -> event.getEntity().getMessagePayload().getCorrelationKey(), event -> event.getEntity().getMessagePayload().getBusinessKey(), event -> event.getEntity().getMessagePayload().getVariables()).contains(Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_RECEIVED, process.getProcessDefinitionId(), process.getId(), process.getProcessDefinitionId(), process.getId(), "startMessagePayload", null, process.getBusinessKey(), singletonMap("message_variable_name", "value")));
// and
List<VariableInstance> variables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(process.getId()).build());
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).contains(tuple("process_variable_name", "value"));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeIT method should_startProcessViaSignal.
@Test
public void should_startProcessViaSignal() {
// when
SignalPayload signalPayload = ProcessPayloadBuilder.signal().withName("The Signal").withVariable("signalVar", "from signal").build();
processRuntimeMock.signal(signalPayload);
Page<ProcessInstance> processInstancePage = processRuntimeMock.processInstances(PAGEABLE);
// then
assertThat(processInstancePage).isNotNull();
assertThat(processInstancePage.getContent()).hasSize(1);
assertThat(processInstancePage.getContent().get(0).getProcessDefinitionKey()).isEqualTo("processWithSignalStart1");
verify(eventPublisher).publishEvent(signalPayload);
// when
List<VariableInstance> variables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(processInstancePage.getContent().get(0)).build());
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).containsExactly(tuple("signalVar", "from signal"));
processRuntimeMock.delete(ProcessPayloadBuilder.delete(processInstancePage.getContent().get(0).getId()));
}
use of org.activiti.api.model.shared.model.VariableInstance in project Activiti by Activiti.
the class ProcessRuntimeIT method should_handleBigDecimalAndDoubleVariables.
@Test
public void should_handleBigDecimalAndDoubleVariables() {
// given
BigDecimal bigDecimalValue = BigDecimal.valueOf(100000, 3);
double doubleValue = 2.0;
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(CATEGORIZE_HUMAN_PROCESS).withVariable("bigDecimalVar", bigDecimalValue).withVariable("doubleVar", doubleValue).build());
// when
List<VariableInstance> variables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(processInstance).build());
// then
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).contains(tuple("bigDecimalVar", bigDecimalValue), tuple("doubleVar", doubleValue));
}
Aggregations