use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationHistoryTest method testStartBeforeAsyncWithVariablesInHistory.
@Deployment(resources = EXCLUSIVE_GATEWAY_ASYNC_TASK_PROCESS)
public void testStartBeforeAsyncWithVariablesInHistory() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway");
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("task2").setVariable("procInstVar", "procInstValue").setVariableLocal("localVar", "localValue").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
HistoricVariableInstance procInstVariable = historyService.createHistoricVariableInstanceQuery().variableName("procInstVar").singleResult();
assertNotNull(procInstVariable);
assertEquals(updatedTree.getId(), procInstVariable.getActivityInstanceId());
assertEquals("procInstVar", procInstVariable.getName());
assertEquals("procInstValue", procInstVariable.getValue());
HistoricDetail procInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(procInstVariable.getId()).singleResult();
assertNotNull(procInstanceVarDetail);
// when starting before/after an activity instance, the activity instance id of the
// execution is null and so is the activity instance id of the historic detail
assertNull(procInstanceVarDetail.getActivityInstanceId());
HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult();
assertNotNull(localVariable);
// the following is null because localVariable is local on a concurrent execution
// but the concurrent execution does not execute an activity at the time the variable is set
assertNull(localVariable.getActivityInstanceId());
assertEquals("localVar", localVariable.getName());
assertEquals("localValue", localVariable.getValue());
HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.getId()).singleResult();
assertNotNull(localInstanceVarDetail);
assertNull(localInstanceVarDetail.getActivityInstanceId());
// end process instance
completeTasksInOrder("task1");
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
completeTasksInOrder("task2");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationHistoryTest method testStartBeforeWithVariablesInHistory.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testStartBeforeWithVariablesInHistory() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway");
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("task2").setVariable("procInstVar", "procInstValue").setVariableLocal("localVar", "localValue").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
HistoricVariableInstance procInstVariable = historyService.createHistoricVariableInstanceQuery().variableName("procInstVar").singleResult();
assertNotNull(procInstVariable);
assertEquals(updatedTree.getId(), procInstVariable.getActivityInstanceId());
assertEquals("procInstVar", procInstVariable.getName());
assertEquals("procInstValue", procInstVariable.getValue());
HistoricDetail procInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(procInstVariable.getId()).singleResult();
assertNotNull(procInstanceVarDetail);
// when starting before/after an activity instance, the activity instance id of the
// execution is null and so is the activity instance id of the historic detail
assertNull(procInstanceVarDetail.getActivityInstanceId());
HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult();
assertNotNull(localVariable);
assertNull(localVariable.getActivityInstanceId());
assertEquals("localVar", localVariable.getName());
assertEquals("localValue", localVariable.getValue());
HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.getId()).singleResult();
assertNotNull(localInstanceVarDetail);
assertNull(localInstanceVarDetail.getActivityInstanceId());
completeTasksInOrder("task1", "task2");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationHistoryTest method testStartBeforeScopeWithVariablesInHistory.
@Deployment(resources = SUBPROCESS_PROCESS)
public void testStartBeforeScopeWithVariablesInHistory() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess");
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("innerTask").setVariable("procInstVar", "procInstValue").setVariableLocal("localVar", "localValue").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
HistoricVariableInstance procInstVariable = historyService.createHistoricVariableInstanceQuery().variableName("procInstVar").singleResult();
assertNotNull(procInstVariable);
assertEquals(updatedTree.getId(), procInstVariable.getActivityInstanceId());
assertEquals("procInstVar", procInstVariable.getName());
assertEquals("procInstValue", procInstVariable.getValue());
HistoricDetail procInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(procInstVariable.getId()).singleResult();
assertNotNull(procInstanceVarDetail);
// when starting before/after an activity instance, the activity instance id of the
// execution is null and so is the activity instance id of the historic detail
assertNull(procInstanceVarDetail.getActivityInstanceId());
HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult();
assertNotNull(localVariable);
assertEquals(updatedTree.getActivityInstances("subProcess")[0].getId(), localVariable.getActivityInstanceId());
assertEquals("localVar", localVariable.getName());
assertEquals("localValue", localVariable.getValue());
HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.getId()).singleResult();
assertNotNull(localInstanceVarDetail);
assertNull(localInstanceVarDetail.getActivityInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class ProcessInstantiationWithVariablesInReturnTest method checkVariables.
private void checkVariables(VariableMap map, int expectedSize) {
List<HistoricVariableInstance> variables = engineRule.getHistoryService().createHistoricVariableInstanceQuery().orderByVariableName().asc().list();
assertEquals(expectedSize, variables.size());
assertEquals(variables.size(), map.size());
for (HistoricVariableInstance instance : variables) {
assertTrue(map.containsKey(instance.getName()));
Object instanceValue = instance.getTypedValue().getValue();
Object mapValue = map.getValueTyped(instance.getName()).getValue();
if (instanceValue == null) {
assertNull(mapValue);
} else if (instanceValue instanceof byte[]) {
assertTrue(Arrays.equals((byte[]) instanceValue, (byte[]) mapValue));
} else {
assertEquals(instanceValue, mapValue);
}
}
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance 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());
}
Aggregations