use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method testCleanupHistoryCaseInstanceTaskDetails.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceTaskDetails() {
// given
// create case instance
CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase");
Task task = taskService.createTaskQuery().singleResult();
taskService.setVariable(task.getId(), "boo", new TestPojo("foo", 123.0));
taskService.setVariable(task.getId(), "goo", 9);
taskService.setVariable(task.getId(), "boo", new TestPojo("foo", 321.0));
// assume
List<HistoricDetail> detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(3, detailsList.size());
terminateAndCloseCaseInstance(caseInstance.getId(), taskService.getVariables(task.getId()));
// when
historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstance.getId()));
// then
detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(0, detailsList.size());
}
use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method testCleanupHistoryCaseInstanceComplexVariable.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceComplexVariable() {
// given
// create case instances
VariableMap variables = Variables.createVariables();
CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase", variables.putValue("pojo", new TestPojo("okay", 13.37)));
caseService.setVariable(caseInstance.getId(), "pojo", "theValue");
// assume
List<HistoricVariableInstance> variablesInstances = historyService.createHistoricVariableInstanceQuery().list();
assertEquals(1, variablesInstances.size());
List<HistoricDetail> detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(2, detailsList.size());
terminateAndCloseCaseInstance(caseInstance.getId(), variables);
// when
historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstance.getId()));
// then
variablesInstances = historyService.createHistoricVariableInstanceQuery().list();
assertEquals(0, variablesInstances.size());
detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(0, detailsList.size());
}
use of org.camunda.bpm.engine.history.HistoricDetail 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.HistoricDetail 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.HistoricDetail 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());
}
Aggregations