use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testSetVariableLocalOnTaskInsideParallelBranch.
@Deployment
public void testSetVariableLocalOnTaskInsideParallelBranch() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
taskService.setVariableLocal(task.getId(), "testVar", "testValue");
ExecutionEntity taskExecution = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(task.getExecutionId()).singleResult();
assertNotNull(taskExecution);
HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
assertEquals(1, query.count());
HistoricVariableInstance variable = query.singleResult();
// the variable is in the user task scope
assertEquals(taskExecution.getActivityInstanceId(), variable.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 testCmmnActivityInstanceIdOnCaseExecution.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCmmnActivityInstanceIdOnCaseExecution() {
// given
caseService.createCaseInstanceByKey("oneTaskCase");
String taskExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
// when
caseService.withCaseExecution(taskExecutionId).setVariableLocal("foo", "bar").execute();
// then
HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("foo").singleResult();
assertNotNull(variable);
assertEquals(taskExecutionId, variable.getActivityInstanceId());
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
HistoricDetail variableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(variable.getId()).singleResult();
assertEquals(taskExecutionId, variableDetail.getActivityInstanceId());
}
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testCmmnActivityInstanceIdOnCaseInstance.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCmmnActivityInstanceIdOnCaseInstance() {
// given
CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase");
String taskExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
// when
caseService.withCaseExecution(taskExecutionId).setVariable("foo", "bar").execute();
// then
HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("foo").singleResult();
assertNotNull(variable);
assertEquals(caseInstance.getId(), variable.getActivityInstanceId());
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
HistoricDetail variableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(variable.getId()).singleResult();
assertEquals(taskExecutionId, variableDetail.getActivityInstanceId());
}
}
Aggregations