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