use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricVariableInstanceSetOnProcessInstance.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testHistoricVariableInstanceSetOnProcessInstance() {
// when
ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").setVariable("aVar", "aValue").startBeforeActivity("task1").execute();
ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId());
// then
HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().variableName("aVar").singleResult();
assertNotNull(historicVariable);
assertEquals(instance.getId(), historicVariable.getProcessInstanceId());
assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId());
assertEquals("aVar", historicVariable.getName());
assertEquals("aValue", historicVariable.getValue());
HistoricDetail historicDetail = historyService.createHistoricDetailQuery().variableInstanceId(historicVariable.getId()).singleResult();
assertEquals(instance.getId(), historicDetail.getProcessInstanceId());
assertNotNull(historicDetail);
// TODO: fix if this is not ok due to CAM-3886
assertEquals(instance.getId(), historicDetail.getActivityInstanceId());
assertTrue(historicDetail instanceof HistoricVariableUpdate);
assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName());
assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TransientVariableTest method testSignalWithTransientVariables.
@Test
public void testSignalWithTransientVariables() {
// given
BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().intermediateCatchEvent("signalCatch").signal("signal").scriptTask("scriptTask").scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariable('abc', foo);").endEvent().done();
testRule.deploy(instance);
runtimeService.startProcessInstanceByKey("Process");
// when
runtimeService.signalEventReceived("signal", Variables.createVariables().putValue("foo", Variables.stringValue("bar", true)));
// then
List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().list();
assertEquals(1, variables.size());
assertEquals("abc", variables.get(0).getName());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TransientVariableTest method testParallelExecutions.
@Test
public void testParallelExecutions() {
// given
BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().parallelGateway().scriptTask().scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariableLocal('abc', foo);").endEvent().moveToLastGateway().scriptTask().scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariableLocal('abc', foo);").endEvent().done();
testRule.deploy(instance);
// when
runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValueTyped("foo", Variables.stringValue("bar", true)));
// then
List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().list();
assertEquals(0, variables.size());
List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery().variableName("abc").list();
assertEquals(2, historicVariables.size());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TransientVariableTest method createVariablesUsingVariableMap.
@Test
public void createVariablesUsingVariableMap() {
// given
BpmnModelInstance simpleInstanceWithListener = Bpmn.createExecutableProcess("Process").startEvent().camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, ReadTransientVariableExecutionListener.class).userTask().endEvent().done();
testRule.deploy(simpleInstanceWithListener);
// when
VariableMap variables = Variables.createVariables();
variables.put(VARIABLE_NAME, Variables.untypedValue(true, true));
runtimeService.startProcessInstanceByKey("Process", variables);
// 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.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TransientVariableTest method createTransientTypedVariablesUsingVariableMap.
@Test
public void createTransientTypedVariablesUsingVariableMap() 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().putValueTyped("a", Variables.stringValue("bar", true)).putValueTyped("b", Variables.booleanValue(true, true)).putValueTyped("c", Variables.byteArrayValue("test".getBytes(), true)).putValueTyped("d", Variables.dateValue(new Date(), true)).putValueTyped("e", Variables.doubleValue(20., true)).putValueTyped("f", Variables.integerValue(10, true)).putValueTyped("g", Variables.longValue((long) 10, true)).putValueTyped("h", Variables.shortValue((short) 10, true)).putValueTyped("i", Variables.objectValue(new Integer(100), true).create()).putValueTyped("j", Variables.untypedValue(null, true)).putValueTyped("k", Variables.untypedValue(Variables.booleanValue(true), true)).putValueTyped("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());
}
Aggregations