Search in sources :

Example 56 with VariableInstance

use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.

the class TransientVariableTest method testStartMessageCorrelationWithTransientVariable.

@Test
public void testStartMessageCorrelationWithTransientVariable() {
    // given
    BpmnModelInstance instance = Bpmn.createExecutableProcess("process").startEvent().message("message").scriptTask("scriptTask").scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariable('abc', foo);").endEvent().done();
    testRule.deploy(instance);
    // when
    runtimeService.createMessageCorrelation("message").setVariable("foo", Variables.stringValue("bar", true)).correlate();
    // then
    List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
    assertEquals(0, variableInstances.size());
    List<HistoricVariableInstance> historicInstances = historyService.createHistoricVariableInstanceQuery().list();
    assertEquals(1, historicInstances.size());
    assertEquals("abc", historicInstances.get(0).getName());
    assertEquals("bar", historicInstances.get(0).getValue());
}
Also used : HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Test(org.junit.Test)

Example 57 with VariableInstance

use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.

the class TransientVariableTest method createTransientVariablesUsingVariableMap.

@Test
public void createTransientVariablesUsingVariableMap() throws URISyntaxException {
    // given
    BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().serviceTask().camundaClass(ReadTransientVariablesOfAllTypesDelegate.class.getName()).userTask("user").endEvent().done();
    testRule.deploy(instance);
    // when
    runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("a", Variables.stringValue("bar", true)).putValue("b", Variables.booleanValue(true, true)).putValue("c", Variables.byteArrayValue("test".getBytes(), true)).putValue("d", Variables.dateValue(new Date(), true)).putValue("e", Variables.doubleValue(20., true)).putValue("f", Variables.integerValue(10, true)).putValue("g", Variables.longValue((long) 10, true)).putValue("h", Variables.shortValue((short) 10, true)).putValue("i", Variables.objectValue(new Integer(100), true).create()).putValue("j", Variables.untypedValue(null, true)).putValue("k", Variables.untypedValue(Variables.booleanValue(true), true)).putValue("l", Variables.fileValue(new File(this.getClass().getClassLoader().getResource("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt").toURI()), true)));
    // then
    List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().list();
    List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
    assertEquals(0, historicVariableInstances.size());
    assertEquals(0, variableInstances.size());
}
Also used : HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 58 with VariableInstance

use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.

the class TransientVariableTest method createTransientVariablesUsingFluentBuilder.

@Test
public void createTransientVariablesUsingFluentBuilder() {
    // given
    BpmnModelInstance simpleInstanceWithListener = Bpmn.createExecutableProcess("Process").startEvent().camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, ReadTransientVariableExecutionListener.class).userTask().endEvent().done();
    testRule.deploy(simpleInstanceWithListener);
    // when
    runtimeService.createProcessInstanceByKey("Process").setVariables(Variables.createVariables().putValue(VARIABLE_NAME, Variables.stringValue("dlsd", true))).execute();
    // then
    List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
    List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().list();
    assertEquals(0, variableInstances.size());
    assertEquals(0, historicVariableInstances.size());
}
Also used : HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Test(org.junit.Test)

Example 59 with VariableInstance

use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.

the class ProcessInstantiationAtActivitiesTest method testSetProcessInstanceVariable.

@Deployment(resources = SUBPROCESS_PROCESS)
public void testSetProcessInstanceVariable() {
    // when
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("subprocess").setVariable("aVariable1", "aValue1").setVariableLocal("aVariable2", "aValue2").setVariables(Variables.createVariables().putValue("aVariable3", "aValue3")).setVariablesLocal(Variables.createVariables().putValue("aVariable4", "aValue4")).startBeforeActivity("innerTask").execute();
    // then
    List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().orderByVariableName().asc().list();
    assertEquals(4, variables.size());
    assertEquals("aVariable1", variables.get(0).getName());
    assertEquals("aValue1", variables.get(0).getValue());
    assertEquals(instance.getId(), variables.get(0).getExecutionId());
    assertEquals("aVariable2", variables.get(1).getName());
    assertEquals("aValue2", variables.get(1).getValue());
    assertEquals(instance.getId(), variables.get(1).getExecutionId());
    assertEquals("aVariable3", variables.get(2).getName());
    assertEquals("aValue3", variables.get(2).getValue());
    assertEquals(instance.getId(), variables.get(2).getExecutionId());
    assertEquals("aVariable4", variables.get(3).getName());
    assertEquals("aValue4", variables.get(3).getValue());
    assertEquals(instance.getId(), variables.get(3).getExecutionId());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 60 with VariableInstance

use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.

the class ProcessInstantiationAtActivitiesTest method testIoMappingInvocation.

@Deployment(resources = IO_PROCESS)
public void testIoMappingInvocation() {
    // when
    runtimeService.createProcessInstanceByKey("ioProcess").startBeforeActivity("innerTask").execute();
    // then no io mappings have been executed
    List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().orderByVariableName().asc().list();
    assertEquals(2, variables.size());
    Execution innerTaskExecution = runtimeService.createExecutionQuery().activityId("innerTask").singleResult();
    VariableInstance innerTaskVariable = variables.get(0);
    assertEquals("innerTaskVariable", innerTaskVariable.getName());
    assertEquals("innerTaskValue", innerTaskVariable.getValue());
    assertEquals(innerTaskExecution.getId(), innerTaskVariable.getExecutionId());
    VariableInstance subProcessVariable = variables.get(1);
    assertEquals("subProcessVariable", subProcessVariable.getName());
    assertEquals("subProcessValue", subProcessVariable.getValue());
    assertEquals(((ExecutionEntity) innerTaskExecution).getParentId(), subProcessVariable.getExecutionId());
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)374 Deployment (org.camunda.bpm.engine.test.Deployment)265 Test (org.junit.Test)167 HashMap (java.util.HashMap)136 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)122 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)93 Task (org.camunda.bpm.engine.task.Task)67 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)39 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)33 Execution (org.camunda.bpm.engine.runtime.Execution)33 VariableMap (org.camunda.bpm.engine.variable.VariableMap)30 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)27 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)26 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)23 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)21 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)17 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)13 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)11 List (java.util.List)10