Search in sources :

Example 81 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class TaskEventResource method deleteEvent.

@RequestMapping(value = "/runtime/tasks/{taskId}/events/{eventId}", method = RequestMethod.DELETE)
public void deleteEvent(@PathVariable("taskId") String taskId, @PathVariable("eventId") String eventId, HttpServletResponse response) {
    // Check if task exists
    Task task = getTaskFromRequest(taskId);
    Event event = taskService.getEvent(eventId);
    if (event == null || event.getTaskId() == null || !event.getTaskId().equals(task.getId())) {
        throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have an event with id '" + event + "'.", Event.class);
    }
    taskService.deleteComment(eventId);
    response.setStatus(HttpStatus.NO_CONTENT.value());
}
Also used : Task(org.activiti.engine.task.Task) Event(org.activiti.engine.task.Event) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 82 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class CallActivityAdvancedTest method testSubProcessWithDataInputOutput.

/**
   * Test case for handing over process variables to a sub process
   */
@Deployment(resources = { "org/activiti/engine/test/bpmn/callactivity/CallActivity.testSubProcessDataInputOutput.bpmn20.xml", "org/activiti/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" })
public void testSubProcessWithDataInputOutput() {
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("superVariable", "Hello from the super process.");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subProcessDataInputOutput", vars);
    // one task in the subprocess should be active after starting the process instance
    TaskQuery taskQuery = taskService.createTaskQuery();
    Task taskBeforeSubProcess = taskQuery.singleResult();
    assertEquals("Task in subprocess", taskBeforeSubProcess.getName());
    assertEquals("Hello from the super process.", runtimeService.getVariable(taskBeforeSubProcess.getProcessInstanceId(), "subVariable"));
    assertEquals("Hello from the super process.", taskService.getVariable(taskBeforeSubProcess.getId(), "subVariable"));
    runtimeService.setVariable(taskBeforeSubProcess.getProcessInstanceId(), "subVariable", "Hello from sub process.");
    // super variable is unchanged
    assertEquals("Hello from the super process.", runtimeService.getVariable(processInstance.getId(), "superVariable"));
    // Completing this task ends the subprocess which leads to a task in the super process
    taskService.complete(taskBeforeSubProcess.getId());
    // one task in the subprocess should be active after starting the process instance
    Task taskAfterSubProcess = taskQuery.singleResult();
    assertEquals("Task in super process", taskAfterSubProcess.getName());
    assertEquals("Hello from sub process.", runtimeService.getVariable(processInstance.getId(), "superVariable"));
    assertEquals("Hello from sub process.", taskService.getVariable(taskAfterSubProcess.getId(), "superVariable"));
    vars.clear();
    vars.put("x", 5l);
    // Completing this task ends the super process which leads to a task in the super process
    taskService.complete(taskAfterSubProcess.getId(), vars);
    // now we are the second time in the sub process but passed variables via expressions
    Task taskInSecondSubProcess = taskQuery.singleResult();
    assertEquals("Task in subprocess", taskInSecondSubProcess.getName());
    assertEquals(10l, runtimeService.getVariable(taskInSecondSubProcess.getProcessInstanceId(), "y"));
    assertEquals(10l, taskService.getVariable(taskInSecondSubProcess.getId(), "y"));
    // Completing this task ends the subprocess which leads to a task in the super process
    taskService.complete(taskInSecondSubProcess.getId());
    // one task in the subprocess should be active after starting the process instance
    Task taskAfterSecondSubProcess = taskQuery.singleResult();
    assertEquals("Task in super process", taskAfterSecondSubProcess.getName());
    assertEquals(15l, runtimeService.getVariable(taskAfterSecondSubProcess.getProcessInstanceId(), "z"));
    assertEquals(15l, taskService.getVariable(taskAfterSecondSubProcess.getId(), "z"));
    // and end last task in Super process
    taskService.complete(taskAfterSecondSubProcess.getId());
    assertProcessEnded(processInstance.getId());
    assertEquals(0, runtimeService.createExecutionQuery().list().size());
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) TaskQuery(org.activiti.engine.task.TaskQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 83 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class CallActivityAdvancedTest method testStartUserIdSetWhenLooping.

@Deployment(resources = { "org/activiti/engine/test/bpmn/callactivity/CallActivity.testStartUserIdSetWhenLooping.bpmn20.xml", "org/activiti/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" })
public void testStartUserIdSetWhenLooping() {
    identityService.setAuthenticatedUserId("kermit");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("loopingCallActivity", CollectionUtil.singletonMap("input", 0));
    for (int i = 1; i < 4; i++) {
        Task task = taskService.createTaskQuery().singleResult();
        assertEquals("Task in subprocess", task.getName());
        identityService.setAuthenticatedUserId("kermit");
        taskService.complete(task.getId(), CollectionUtil.singletonMap("input", i));
    }
    identityService.setAuthenticatedUserId(null);
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("Final task", task.getName());
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).list();
        assertEquals(3, historicProcessInstances.size());
        for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
            assertNotNull(historicProcessInstance.getStartUserId());
            assertNotNull(historicProcessInstance.getStartTime());
            assertNotNull(historicProcessInstance.getEndTime());
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 84 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class TaskServiceTest method testAddCandidateGroupUnexistingTask.

public void testAddCandidateGroupUnexistingTask() {
    Group group = identityService.newGroup("group");
    identityService.saveGroup(group);
    try {
        taskService.addCandidateGroup("unexistingTaskId", group.getId());
        fail("ActivitiException expected");
    } catch (ActivitiObjectNotFoundException ae) {
        assertTextPresent("Cannot find task with id unexistingTaskId", ae.getMessage());
        assertEquals(Task.class, ae.getObjectClass());
    }
    identityService.deleteGroup(group.getId());
}
Also used : Group(org.activiti.engine.identity.Group) Task(org.activiti.engine.task.Task) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 85 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class TaskServiceTest method testSetAssigneeUnexistingTask.

public void testSetAssigneeUnexistingTask() {
    User user = identityService.newUser("user");
    identityService.saveUser(user);
    try {
        taskService.setAssignee("unexistingTaskId", user.getId());
        fail("ActivitiException expected");
    } catch (ActivitiObjectNotFoundException ae) {
        assertTextPresent("Cannot find task with id unexistingTaskId", ae.getMessage());
        assertEquals(Task.class, ae.getObjectClass());
    }
    identityService.deleteUser(user.getId());
}
Also used : Task(org.activiti.engine.task.Task) User(org.activiti.engine.identity.User) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Aggregations

Task (org.activiti.engine.task.Task)955 Deployment (org.activiti.engine.test.Deployment)548 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)502 HashMap (java.util.HashMap)197 Test (org.junit.Test)123 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)109 ArrayList (java.util.ArrayList)74 Date (java.util.Date)65 Execution (org.activiti.engine.runtime.Execution)59 DelegateTask (org.activiti.engine.delegate.DelegateTask)54 TaskQuery (org.activiti.engine.task.TaskQuery)54 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)51 Job (org.activiti.engine.runtime.Job)49 Calendar (java.util.Calendar)44 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)44 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)44 JsonNode (com.fasterxml.jackson.databind.JsonNode)41 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)41 JSONObject (org.json.simple.JSONObject)40 TasksClient (org.alfresco.rest.workflow.api.tests.WorkflowApiClient.TasksClient)38