use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method testCleanupHistoryCaseInstanceDetails.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceDetails() {
// given
// create case instances
String variableNameCase1 = "varName1";
CaseInstance caseInstance1 = caseService.createCaseInstanceByKey("oneTaskCase", Variables.createVariables().putValue(variableNameCase1, "value1"));
CaseInstance caseInstance2 = caseService.createCaseInstanceByKey("oneTaskCase", Variables.createVariables().putValue("varName2", "value2"));
caseService.setVariable(caseInstance1.getId(), variableNameCase1, "theValue");
// assume
List<HistoricDetail> detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(3, detailsList.size());
caseService.terminateCaseExecution(caseInstance1.getId(), caseService.getVariables(caseInstance1.getId()));
caseService.terminateCaseExecution(caseInstance2.getId(), caseService.getVariables(caseInstance2.getId()));
caseService.closeCaseInstance(caseInstance1.getId());
caseService.closeCaseInstance(caseInstance2.getId());
// when
historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstance1.getId(), caseInstance2.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 ProcessInstanceModificationHistoryTest method testStartTransitionWithVariablesInHistory.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testStartTransitionWithVariablesInHistory() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway");
runtimeService.createProcessInstanceModification(processInstance.getId()).startTransition("flow2").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);
assertEquals(updatedTree.getId(), procInstVariable.getActivityInstanceId());
HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult();
assertNotNull(localVariable);
assertEquals(updatedTree.getId(), procInstVariable.getActivityInstanceId());
assertEquals("localVar", localVariable.getName());
assertEquals("localValue", localVariable.getValue());
HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.getId()).singleResult();
assertNotNull(localInstanceVarDetail);
// 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(localInstanceVarDetail.getActivityInstanceId());
completeTasksInOrder("task1", "task1");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class TaskServiceTest method checkHistoricVariableUpdateEntity.
private void checkHistoricVariableUpdateEntity(String variableName, String processInstanceId) {
if (processEngineConfiguration.getHistoryLevel().getId() == ProcessEngineConfigurationImpl.HISTORYLEVEL_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 VariableListenerTest method FAILING_testListenerDoesNotInterfereWithHistory.
/**
* TODO: add when history for case execution variables is implemented
*/
@Deployment
public void FAILING_testListenerDoesNotInterfereWithHistory() {
CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();
// when i set a variable that causes the listener to be notified
// and that listener sets the same variable to another value (here "value2")
caseService.withCaseExecution(caseInstance.getId()).setVariableLocal("variable", "value1").execute();
// then there should be two historic variable updates for both values
if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_FULL.getId()) {
List<HistoricDetail> variableUpdates = historyService.createHistoricDetailQuery().variableUpdates().list();
assertEquals(2, variableUpdates.size());
for (HistoricDetail detail : variableUpdates) {
HistoricVariableUpdate update = (HistoricVariableUpdate) detail;
boolean update1Processed = false;
boolean update2Processed = false;
if (!update1Processed && update.getValue().equals("value1")) {
update1Processed = true;
} else if (!update2Processed && update.getValue().equals("value2")) {
update2Processed = true;
} else {
fail("unexpected variable update");
}
}
}
}
use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testCmmnActivityInstanceIdOnTask.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCmmnActivityInstanceIdOnTask() {
// given
CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase");
String taskExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
Task task = taskService.createTaskQuery().singleResult();
// when
taskService.setVariable(task.getId(), "foo", "bar");
// 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