use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricVariableInstanceForSingleActivityInstantiation.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testHistoricVariableInstanceForSingleActivityInstantiation() {
// when
ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").startBeforeActivity("task1").setVariable("aVar", "aValue").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
assertNull(historicDetail.getActivityInstanceId());
assertTrue(historicDetail instanceof HistoricVariableUpdate);
assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName());
assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue());
}
use of org.camunda.bpm.engine.history.HistoricDetail 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.HistoricDetail in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method checkHistoricVariableUpdateEntity.
private void checkHistoricVariableUpdateEntity(String variableName, String processInstanceId) {
if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
boolean deletedVariableUpdateFound = false;
List<HistoricDetail> resultSet = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).list();
for (HistoricDetail currentHistoricDetail : resultSet) {
assertTrue(currentHistoricDetail instanceof HistoricDetailVariableInstanceUpdateEntity);
HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = (HistoricDetailVariableInstanceUpdateEntity) currentHistoricDetail;
if (historicVariableUpdate.getName().equals(variableName)) {
if (historicVariableUpdate.getValue() == null) {
if (deletedVariableUpdateFound) {
fail("Mismatch: A HistoricVariableUpdateEntity with a null value already found");
} else {
deletedVariableUpdateFound = true;
}
}
}
}
assertTrue(deletedVariableUpdateFound);
}
}
use of org.camunda.bpm.engine.history.HistoricDetail 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.HistoricDetail 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