use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testProcessTaskUpdateVariablesWithUpdateTaskPermissionOnAnyProcessDefinition.
public void testProcessTaskUpdateVariablesWithUpdateTaskPermissionOnAnyProcessDefinition() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String taskId = selectSingleTask().getId();
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, UPDATE_TASK);
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
// when (1)
((TaskServiceImpl) taskService).updateVariables(taskId, getVariables(), null);
// then (1)
disableAuthorization();
verifyQueryResults(query, 1);
enableAuthorization();
// when (2)
((TaskServiceImpl) taskService).updateVariables(taskId, null, Arrays.asList(VARIABLE_NAME));
// then (2)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
// when (3)
((TaskServiceImpl) taskService).updateVariables(taskId, getVariables(), Arrays.asList(VARIABLE_NAME));
// then (3)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testProcessTaskUpdateVariablesLocalWithUpdateTaskPermissionOnProcessDefinition.
public void testProcessTaskUpdateVariablesLocalWithUpdateTaskPermissionOnProcessDefinition() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String taskId = selectSingleTask().getId();
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_TASK);
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();
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testCaseTaskUpdateVariables.
// TaskServiceImpl#updateVariablesLocal() (case task) ////////////////////////////////////////////
public void testCaseTaskUpdateVariables() {
// given
createCaseInstanceByKey(CASE_KEY);
String taskId = selectSingleTask().getId();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
// when (1)
((TaskServiceImpl) taskService).updateVariables(taskId, getVariables(), null);
// then (1)
disableAuthorization();
verifyQueryResults(query, 1);
enableAuthorization();
// when (2)
((TaskServiceImpl) taskService).updateVariables(taskId, null, Arrays.asList(VARIABLE_NAME));
// then (2)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
// when (3)
((TaskServiceImpl) taskService).updateVariables(taskId, getVariables(), Arrays.asList(VARIABLE_NAME));
// then (3)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testUpdateVariablesLocal.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneSubProcess.bpmn20.xml" })
@Test
public void testUpdateVariablesLocal() {
Map<String, Object> globalVars = new HashMap<String, Object>();
globalVars.put("variable4", "value4");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startSimpleSubProcess", globalVars);
Task currentTask = taskService.createTaskQuery().singleResult();
Map<String, Object> localVars = new HashMap<String, Object>();
localVars.put("variable1", "value1");
localVars.put("variable2", "value2");
localVars.put("variable3", "value3");
taskService.setVariablesLocal(currentTask.getId(), localVars);
Map<String, Object> modifications = new HashMap<String, Object>();
modifications.put("variable1", "anotherValue1");
modifications.put("variable2", "anotherValue2");
List<String> deletions = new ArrayList<String>();
deletions.add("variable2");
deletions.add("variable3");
deletions.add("variable4");
((TaskServiceImpl) taskService).updateVariablesLocal(currentTask.getId(), modifications, deletions);
assertEquals("anotherValue1", taskService.getVariable(currentTask.getId(), "variable1"));
assertNull(taskService.getVariable(currentTask.getId(), "variable2"));
assertNull(taskService.getVariable(currentTask.getId(), "variable3"));
assertEquals("value4", runtimeService.getVariable(processInstance.getId(), "variable4"));
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testUpdateVariables.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneSubProcess.bpmn20.xml" })
@Test
public void testUpdateVariables() {
Map<String, Object> globalVars = new HashMap<String, Object>();
globalVars.put("variable4", "value4");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startSimpleSubProcess", globalVars);
Task currentTask = taskService.createTaskQuery().singleResult();
Map<String, Object> localVars = new HashMap<String, Object>();
localVars.put("variable1", "value1");
localVars.put("variable2", "value2");
localVars.put("variable3", "value3");
taskService.setVariablesLocal(currentTask.getId(), localVars);
Map<String, Object> modifications = new HashMap<String, Object>();
modifications.put("variable1", "anotherValue1");
modifications.put("variable2", "anotherValue2");
List<String> deletions = new ArrayList<String>();
deletions.add("variable2");
deletions.add("variable3");
deletions.add("variable4");
((TaskServiceImpl) taskService).updateVariables(currentTask.getId(), modifications, deletions);
assertEquals("anotherValue1", taskService.getVariable(currentTask.getId(), "variable1"));
assertNull(taskService.getVariable(currentTask.getId(), "variable2"));
assertNull(taskService.getVariable(currentTask.getId(), "variable3"));
assertNull(runtimeService.getVariable(processInstance.getId(), "variable4"));
}
Aggregations