use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskVariableLocalRestResourceInteractionTest method testLocalVariableModification.
@Test
public void testLocalVariableModification() {
TaskServiceImpl taskServiceMock = mockTaskServiceImpl();
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
String variableKey = "aKey";
int variableValue = 123;
Map<String, Object> modifications = VariablesBuilder.create().variable(variableKey, variableValue).getVariables();
messageBodyJson.put("modifications", modifications);
List<String> deletions = new ArrayList<String>();
deletions.add("deleteKey");
messageBodyJson.put("deletions", deletions);
given().pathParam("id", EXAMPLE_TASK_ID).contentType(ContentType.JSON).body(messageBodyJson).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(SINGLE_TASK_MODIFY_VARIABLES_URL);
Map<String, Object> expectedModifications = new HashMap<String, Object>();
expectedModifications.put(variableKey, variableValue);
verify(taskServiceMock).updateVariablesLocal(eq(EXAMPLE_TASK_ID), argThat(new EqualsMap(expectedModifications)), argThat(new EqualsList(deletions)));
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskVariableLocalRestResourceInteractionTest method mockTaskServiceImpl.
private TaskServiceImpl mockTaskServiceImpl() {
TaskServiceImpl taskServiceMock = mock(TaskServiceImpl.class);
when(processEngine.getTaskService()).thenReturn(taskServiceMock);
return taskServiceMock;
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskVariableRestResourceInteractionTest method testVariableModification.
@Test
public void testVariableModification() {
TaskServiceImpl taskServiceMock = mockTaskServiceImpl();
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
String variableKey = "aKey";
int variableValue = 123;
Map<String, Object> modifications = VariablesBuilder.create().variable(variableKey, variableValue).getVariables();
messageBodyJson.put("modifications", modifications);
List<String> deletions = new ArrayList<String>();
deletions.add("deleteKey");
messageBodyJson.put("deletions", deletions);
given().pathParam("id", EXAMPLE_TASK_ID).contentType(ContentType.JSON).body(messageBodyJson).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(SINGLE_TASK_MODIFY_VARIABLES_URL);
Map<String, Object> expectedModifications = new HashMap<String, Object>();
expectedModifications.put(variableKey, variableValue);
verify(taskServiceMock).updateVariables(eq(EXAMPLE_TASK_ID), argThat(new EqualsMap(expectedModifications)), argThat(new EqualsList(deletions)));
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskVariablesResource method updateVariableEntities.
protected void updateVariableEntities(VariableMap modifications, List<String> deletions) {
TaskServiceImpl taskService = (TaskServiceImpl) engine.getTaskService();
taskService.updateVariables(resourceId, modifications, deletions);
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testProcessTaskUpdateVariablesLocalWithUpdatePermissionOnAnyTask.
public void testProcessTaskUpdateVariablesLocalWithUpdatePermissionOnAnyTask() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String taskId = selectSingleTask().getId();
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();
}
Aggregations