Search in sources :

Example 6 with VariableInstance

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

Example 7 with VariableInstance

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();
}
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)

Example 8 with VariableInstance

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"));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Pageable(org.activiti.api.runtime.shared.query.Pageable) TaskBaseRuntime(org.activiti.spring.boot.tasks.TaskBaseRuntime) ProcessRuntimeEvent(org.activiti.api.process.model.events.ProcessRuntimeEvent) Task(org.activiti.api.task.model.Task) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SecurityUtil(org.activiti.spring.boot.security.util.SecurityUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) MessagePayloadBuilder(org.activiti.api.process.model.builders.MessagePayloadBuilder) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) ProcessRuntimeEventListener(org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener) ArrayList(java.util.ArrayList) ProcessRuntime(org.activiti.api.process.runtime.ProcessRuntime) LocalEventSource(org.activiti.test.LocalEventSource) Collections.singletonMap(java.util.Collections.singletonMap) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) MessageSubscriptionEvent(org.activiti.api.process.model.events.MessageSubscriptionEvent) TaskRuntimeEvent(org.activiti.api.task.model.events.TaskRuntimeEvent) StartMessageDeploymentDefinition(org.activiti.api.process.model.StartMessageDeploymentDefinition) TaskRuntime(org.activiti.api.task.runtime.TaskRuntime) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Tuple(org.assertj.core.groups.Tuple) Assertions.tuple(org.assertj.core.api.Assertions.tuple) TaskPayloadBuilder(org.activiti.api.task.model.builders.TaskPayloadBuilder) TestComponent(org.springframework.boot.test.context.TestComponent) RuntimeEvent(org.activiti.api.model.shared.event.RuntimeEvent) StartMessageDeployedEvents(org.activiti.api.runtime.event.impl.StartMessageDeployedEvents) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) MessageTestConfiguration(org.activiti.spring.boot.MessageTestConfiguration) Import(org.springframework.context.annotation.Import) EventListener(org.springframework.context.event.EventListener) Page(org.activiti.api.runtime.shared.query.Page) MessageSubscriptionCancelledEvent(org.activiti.api.process.model.events.MessageSubscriptionCancelledEvent) Test(org.junit.jupiter.api.Test) StartMessageSubscription(org.activiti.api.process.model.StartMessageSubscription) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) StartMessageDeployedEvent(org.activiti.api.process.model.events.StartMessageDeployedEvent) BPMNMessageEvent(org.activiti.api.process.model.events.BPMNMessageEvent) 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 9 with VariableInstance

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

Example 10 with VariableInstance

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));
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) BigDecimal(java.math.BigDecimal) 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