use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testSetVariableOnServiceTaskInsideSubProcess.
@Deployment
public void testSetVariableOnServiceTaskInsideSubProcess() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
assertEquals(1, query.count());
HistoricVariableInstance variable = query.singleResult();
// the variable is in the process instance scope
assertEquals(pi.getId(), variable.getActivityInstanceId());
assertProcessEnded(pi.getId());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testSetVariableOnProcessInstanceStart.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSetVariableOnProcessInstanceStart() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("testVar", "testValue");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
assertEquals(1, query.count());
HistoricVariableInstance variable = query.singleResult();
assertNotNull(variable);
// the variable is in the process instance scope
assertEquals(pi.getId(), variable.getActivityInstanceId());
taskService.complete(taskService.createTaskQuery().singleResult().getId());
assertProcessEnded(pi.getId());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testSetVariableOnProcessIntanceStartAndSetVariableLocalOnUserTask.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSetVariableOnProcessIntanceStartAndSetVariableLocalOnUserTask() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("testVar", "testValue");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
taskService.setVariableLocal(task.getId(), "testVar", "anotherTestValue");
ExecutionEntity taskExecution = (ExecutionEntity) runtimeService.createExecutionQuery().singleResult();
assertNotNull(taskExecution);
HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
assertEquals(2, query.count());
List<HistoricVariableInstance> result = query.list();
HistoricVariableInstance firstVar = result.get(0);
assertEquals("testVar", firstVar.getVariableName());
assertEquals("testValue", firstVar.getValue());
// the variable is in the process instance scope
assertEquals(pi.getId(), firstVar.getActivityInstanceId());
HistoricVariableInstance secondVar = result.get(1);
assertEquals("testVar", secondVar.getVariableName());
assertEquals("anotherTestValue", secondVar.getValue());
// the variable is in the task scope
assertEquals(taskExecution.getActivityInstanceId(), secondVar.getActivityInstanceId());
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testSetVariableOnUserTaskInsideSubProcess.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneSubProcess.bpmn20.xml" })
public void testSetVariableOnUserTaskInsideSubProcess() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("startSimpleSubProcess");
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
taskService.setVariable(task.getId(), "testVar", "testValue");
HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
assertEquals(1, query.count());
HistoricVariableInstance variable = query.singleResult();
// the variable is in the process instance scope
assertEquals(pi.getId(), variable.getActivityInstanceId());
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testSetVariableOnTaskInsideParallelBranch.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricVariableInstanceScopeTest.testSetVariableLocalOnTaskInsideParallelBranch.bpmn" })
public void testSetVariableOnTaskInsideParallelBranch() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
taskService.setVariable(task.getId(), "testVar", "testValue");
HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
assertEquals(1, query.count());
HistoricVariableInstance variable = query.singleResult();
// the variable is in the process instance scope
assertEquals(pi.getId(), variable.getActivityInstanceId());
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
}
Aggregations