use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class CompensateEventHistoryTest method FAILING_testDefaultCompensationHandlerHistoryVariableInstance.
/**
* Fix CAM-4351
*/
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventHistoryTest.testDefaultCompensationHandlerHistory.bpmn20.xml")
public void FAILING_testDefaultCompensationHandlerHistoryVariableInstance() {
// given a process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("defaultHandlerProcess");
// when throwing compensation
Task beforeCompensationTask = taskService.createTaskQuery().singleResult();
taskService.complete(beforeCompensationTask.getId());
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
String compensationHandlerActivityInstanceId = tree.getActivityInstances("compensationHandler")[0].getId();
// .. setting a variable via task service API
Task compensationHandler = taskService.createTaskQuery().singleResult();
runtimeService.setVariableLocal(compensationHandler.getExecutionId(), "apiVariable", "someValue");
// .. and completing compensation
taskService.complete(compensationHandler.getId());
// then there is a historic variable instance for the variable set by API
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().singleResult();
assertNotNull(historicVariableInstance);
assertEquals(compensationHandlerActivityInstanceId, historicVariableInstance.getActivityInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testStandaloneTaskRemoveVariablesLocalWithReadPermissionOnTask.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testStandaloneTaskRemoveVariablesLocalWithReadPermissionOnTask() {
// given
String taskId = "myTask";
createTask(taskId);
createGrantAuthorization(TASK, taskId, userId, UPDATE);
disableAuthorization();
taskService.setVariable(taskId, VARIABLE_NAME, VARIABLE_VALUE);
enableAuthorization();
// when
taskService.removeVariablesLocal(taskId, Arrays.asList(VARIABLE_NAME));
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
verifyQueryResults(query, 0);
enableAuthorization();
deleteTask(taskId, true);
HistoricVariableInstance deletedVariable = historyService.createHistoricVariableInstanceQuery().includeDeleted().singleResult();
Assert.assertEquals("DELETED", deletedVariable.getState());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testStandaloneTaskRemoveVariablesLocalWithReadPermissionOnAnyTask.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testStandaloneTaskRemoveVariablesLocalWithReadPermissionOnAnyTask() {
// given
String taskId = "myTask";
createTask(taskId);
createGrantAuthorization(TASK, ANY, userId, UPDATE);
disableAuthorization();
taskService.setVariable(taskId, VARIABLE_NAME, VARIABLE_VALUE);
enableAuthorization();
// when
taskService.removeVariablesLocal(taskId, Arrays.asList(VARIABLE_NAME));
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
verifyQueryResults(query, 0);
enableAuthorization();
deleteTask(taskId, true);
HistoricVariableInstance deletedVariable = historyService.createHistoricVariableInstanceQuery().includeDeleted().singleResult();
Assert.assertEquals("DELETED", deletedVariable.getState());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class HistoryServiceTest method testNativeHistoricVariableInstanceTest.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testNativeHistoricVariableInstanceTest() {
Date date = Calendar.getInstance().getTime();
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("stringVar", "abcdef");
vars.put("dateVar", date);
runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS, vars);
assertEquals(2, historyService.createNativeHistoricVariableInstanceQuery().sql("SELECT count(*) FROM " + managementService.getTableName(HistoricVariableInstance.class)).count());
assertEquals(1, historyService.createNativeHistoricVariableInstanceQuery().sql("SELECT * FROM " + managementService.getTableName(HistoricVariableInstance.class)).listPage(0, 1).size());
List<HistoricVariableInstance> variables = historyService.createNativeHistoricVariableInstanceQuery().sql("SELECT * FROM " + managementService.getTableName(HistoricVariableInstance.class)).list();
assertEquals(2, variables.size());
for (HistoricVariableInstance variable : variables) {
assertTrue(vars.containsKey(variable.getName()));
assertEquals(vars.get(variable.getName()), variable.getValue());
vars.remove(variable.getName());
}
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance 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());
}
Aggregations