use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class TaskRestServiceInteractionTest method testPutUpdateTaskLowercaseDelegationState.
@Test
public void testPutUpdateTaskLowercaseDelegationState() {
Map<String, Object> json = new HashMap<String, Object>();
json.put("delegationState", "pending");
Task newTask = mock(Task.class);
when(taskServiceMock.newTask(anyString())).thenReturn(newTask);
given().pathParam("id", EXAMPLE_TASK_ID).body(json).contentType(ContentType.JSON).header("accept", MediaType.APPLICATION_JSON).expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(SINGLE_TASK_URL);
verify(mockTask).setDelegationState(DelegationState.PENDING);
verify(taskServiceMock).saveTask(mockTask);
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class TaskRestServiceImpl method getHalTasks.
public HalTaskList getHalTasks(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
TaskQueryDto queryDto = new TaskQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
ProcessEngine engine = getProcessEngine();
TaskQuery query = queryDto.toQuery(engine);
// get list of tasks
List<Task> matchingTasks = executeTaskQuery(firstResult, maxResults, query);
// get total count
long count = query.count();
return HalTaskList.generate(matchingTasks, count, engine);
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class TaskRestServiceImpl method createTask.
public void createTask(TaskDto taskDto) {
ProcessEngine engine = getProcessEngine();
TaskService taskService = engine.getTaskService();
Task newTask = taskService.newTask(taskDto.getId());
taskDto.updateTask(newTask);
try {
taskService.saveTask(newTask);
} catch (NotValidException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, "Could not save task: " + e.getMessage());
}
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class MockTaskBuilder method build.
public Task build() {
Task mockTask = mock(Task.class);
when(mockTask.getId()).thenReturn(id);
when(mockTask.getName()).thenReturn(name);
when(mockTask.getAssignee()).thenReturn(assignee);
when(mockTask.getCreateTime()).thenReturn(createTime);
when(mockTask.getDueDate()).thenReturn(dueDate);
when(mockTask.getFollowUpDate()).thenReturn(followUpDate);
when(mockTask.getDelegationState()).thenReturn(delegationState);
when(mockTask.getDescription()).thenReturn(description);
when(mockTask.getExecutionId()).thenReturn(executionId);
when(mockTask.getOwner()).thenReturn(owner);
when(mockTask.getParentTaskId()).thenReturn(parentTaskId);
when(mockTask.getPriority()).thenReturn(priority);
when(mockTask.getProcessDefinitionId()).thenReturn(processDefinitionId);
when(mockTask.getProcessInstanceId()).thenReturn(processInstanceId);
when(mockTask.getTaskDefinitionKey()).thenReturn(taskDefinitionKey);
when(mockTask.getCaseDefinitionId()).thenReturn(caseDefinitionId);
when(mockTask.getCaseInstanceId()).thenReturn(caseInstanceId);
when(mockTask.getCaseExecutionId()).thenReturn(caseExecutionId);
when(mockTask.getFormKey()).thenReturn(formKey);
when(mockTask.getTenantId()).thenReturn(tenantId);
return mockTask;
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class JavaSerializationTest method testStandaloneTaskVariable.
public void testStandaloneTaskVariable() {
Task task = taskService.newTask();
task.setName("gonzoTask");
taskService.saveTask(task);
String taskId = task.getId();
try {
taskService.setVariable(taskId, "instrument", Variables.serializedObjectValue("trumpet").serializationDataFormat(Variables.SerializationDataFormats.JAVA).create());
fail("Exception is expected.");
} catch (ProcessEngineException ex) {
assertEquals("ENGINE-17007 Cannot set variable with name instrument. Java serialization format is prohibited", ex.getMessage());
} finally {
taskService.deleteTask(taskId, true);
}
}
Aggregations