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());
}
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());
}
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());
}
}
}
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());
}
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());
}
Aggregations