use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskVariableRestResourceInteractionTest method testVariableModificationThrowsAuthorizationException.
@Test
public void testVariableModificationThrowsAuthorizationException() {
String variableKey = "aKey";
int variableValue = 123;
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
Map<String, Object> modifications = VariablesBuilder.create().variable(variableKey, variableValue).getVariables();
messageBodyJson.put("modifications", modifications);
TaskServiceImpl taskServiceMock = mockTaskServiceImpl();
String message = "excpected exception";
doThrow(new AuthorizationException(message)).when(taskServiceMock).updateVariables(anyString(), any(Map.class), any(List.class));
given().pathParam("id", EXAMPLE_TASK_ID).contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", is(AuthorizationException.class.getSimpleName())).body("message", is(message)).when().post(SINGLE_TASK_MODIFY_VARIABLES_URL);
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskVariableRestResourceInteractionTest method testVariableModificationForNonExistingTaskId.
@Test
public void testVariableModificationForNonExistingTaskId() {
TaskServiceImpl taskServiceMock = mockTaskServiceImpl();
doThrow(new ProcessEngineException("Cannot find task with id " + NON_EXISTING_ID)).when(taskServiceMock).updateVariables(anyString(), any(Map.class), any(List.class));
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);
given().pathParam("id", NON_EXISTING_ID).contentType(ContentType.JSON).body(messageBodyJson).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("Cannot modify variables for task " + NON_EXISTING_ID + ": Cannot find task with id " + NON_EXISTING_ID)).when().post(SINGLE_TASK_MODIFY_VARIABLES_URL);
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl in project camunda-bpm-platform by camunda.
the class TaskVariableRestResourceInteractionTest 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 LocalTaskVariablesResource method updateVariableEntities.
protected void updateVariableEntities(VariableMap modifications, List<String> deletions) {
TaskServiceImpl taskService = (TaskServiceImpl) engine.getTaskService();
taskService.updateVariablesLocal(resourceId, modifications, deletions);
}
use of org.camunda.bpm.engine.impl.TaskServiceImpl 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());
}
Aggregations