Search in sources :

Example 26 with VariableInstance

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"));
}
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 27 with VariableInstance

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"));
}
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 28 with VariableInstance

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

Example 29 with VariableInstance

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"));
}
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 30 with VariableInstance

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"));
    });
}
Also used : 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)

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