Search in sources :

Example 16 with Task

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);
}
Also used : Task(org.camunda.bpm.engine.task.Task) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 17 with Task

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);
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQueryDto(org.camunda.bpm.engine.rest.dto.task.TaskQueryDto) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 18 with Task

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());
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) NotValidException(org.camunda.bpm.engine.exception.NotValidException) TaskService(org.camunda.bpm.engine.TaskService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 19 with Task

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;
}
Also used : Task(org.camunda.bpm.engine.task.Task)

Example 20 with Task

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);
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Aggregations

Task (org.camunda.bpm.engine.task.Task)1654 Deployment (org.camunda.bpm.engine.test.Deployment)788 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)660 Test (org.junit.Test)648 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)230 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)190 HashMap (java.util.HashMap)140 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)139 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)108 Execution (org.camunda.bpm.engine.runtime.Execution)99 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)98 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)87 Job (org.camunda.bpm.engine.runtime.Job)71 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)67 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)52 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)46 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)46 Times (org.camunda.bpm.qa.upgrade.Times)46 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)45 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)45