use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TaskListenerTest method testScriptResourceListener.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/tasklistener/TaskListenerTest.testScriptResourceListener.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/tasklistener/taskListener.groovy" })
public void testScriptResourceListener() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertTrue((Boolean) runtimeService.getVariable(processInstance.getId(), "create"));
taskService.setAssignee(task.getId(), "test");
assertTrue((Boolean) runtimeService.getVariable(processInstance.getId(), "assignment"));
taskService.complete(task.getId());
assertTrue((Boolean) runtimeService.getVariable(processInstance.getId(), "complete"));
task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
if (processEngineConfiguration.getHistoryLevel().getId() >= HISTORYLEVEL_AUDIT) {
HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("delete").singleResult();
assertNotNull(variable);
assertTrue((Boolean) variable.getValue());
}
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance 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.HistoricVariableInstance 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.HistoricVariableInstance 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.HistoricVariableInstance 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());
}
Aggregations