use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testStandaloneTaskRemoveVariableLocalWithReadPermissionOnAnyTask.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testStandaloneTaskRemoveVariableLocalWithReadPermissionOnAnyTask() {
// given
String taskId = "myTask";
createTask(taskId);
createGrantAuthorization(TASK, ANY, userId, UPDATE);
disableAuthorization();
taskService.setVariable(taskId, VARIABLE_NAME, VARIABLE_VALUE);
enableAuthorization();
// when
taskService.removeVariableLocal(taskId, 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 testStandaloneTaskUpdateVariablesLocalWithReadPermissionOnAnyTask.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testStandaloneTaskUpdateVariablesLocalWithReadPermissionOnAnyTask() {
// given
String taskId = "myTask";
createTask(taskId);
createGrantAuthorization(TASK, ANY, userId, UPDATE);
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
// when (1)
((TaskServiceImpl) taskService).updateVariablesLocal(taskId, getVariables(), null);
// then (1)
disableAuthorization();
verifyQueryResults(query, 1);
enableAuthorization();
// when (2)
((TaskServiceImpl) taskService).updateVariablesLocal(taskId, null, Arrays.asList(VARIABLE_NAME));
// then (2)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
// when (3)
((TaskServiceImpl) taskService).updateVariablesLocal(taskId, getVariables(), Arrays.asList(VARIABLE_NAME));
// then (3)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
deleteTask(taskId, true);
List<HistoricVariableInstance> deletedVariables = historyService.createHistoricVariableInstanceQuery().includeDeleted().list();
Assert.assertEquals("DELETED", deletedVariables.get(0).getState());
Assert.assertEquals("DELETED", deletedVariables.get(1).getState());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testStandaloneTaskRemoveVariableLocalWithReadPermissionOnTask.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testStandaloneTaskRemoveVariableLocalWithReadPermissionOnTask() {
// given
String taskId = "myTask";
createTask(taskId);
createGrantAuthorization(TASK, taskId, userId, UPDATE);
disableAuthorization();
taskService.setVariable(taskId, VARIABLE_NAME, VARIABLE_VALUE);
enableAuthorization();
// when
taskService.removeVariableLocal(taskId, 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 CompensateEventHistoryTest method FAILING_testBoundaryCompensationHandlerHistoryVariableInstance.
/**
* Fix CAM-4351
*/
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventHistoryTest.testBoundaryCompensationHandlerHistory.bpmn20.xml")
public void FAILING_testBoundaryCompensationHandlerHistoryVariableInstance() {
// given a process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("boundaryHandlerProcess");
// when throwing compensation
Task beforeCompensationTask = taskService.createTaskQuery().singleResult();
taskService.complete(beforeCompensationTask.getId());
String compensationHandlerActivityInstanceId = runtimeService.getActivityInstance(processInstance.getId()).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 ExecutionListenerTest method testScriptResourceListener.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/executionlistener/ExecutionListenerTest.testScriptResourceListener.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/executionlistener/executionListener.groovy" })
public void testScriptResourceListener() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
assertTrue(processInstance.isEnded());
if (processEngineRule.getProcessEngineConfiguration().getHistoryLevel().getId() >= HISTORYLEVEL_AUDIT) {
HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
long count = query.count();
assertEquals(5, count);
HistoricVariableInstance variableInstance = null;
String[] variableNames = new String[] { "start-start", "start-end", "start-take", "end-start", "end-end" };
for (String variableName : variableNames) {
variableInstance = query.variableName(variableName).singleResult();
assertNotNull("Unable ot find variable with name '" + variableName + "'", variableInstance);
assertTrue("Variable '" + variableName + "' should be set to true", (Boolean) variableInstance.getValue());
}
}
}
Aggregations