use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetTaskById.
@Test
public void testGetTaskById() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance instance = processService.getProcessInstance(processInstanceId);
assertNotNull(instance);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
UserTaskInstanceDesc userTask = runtimeDataService.getTaskById(taskId);
assertNotNull(userTask);
assertEquals(processInstanceId, userTask.getProcessInstanceId());
assertEquals("Write a Document", userTask.getName());
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessInstanceByCorrelationKey.
@Test
public void testGetProcessInstanceByCorrelationKey() {
Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", key);
assertNotNull(processInstanceId);
ProcessInstanceDesc instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
assertNotNull(instance);
assertEquals(1, (int) instance.getState());
assertEquals("org.jbpm.writedocument", instance.getProcessId());
assertEquals("my business key", instance.getCorrelationKey());
List<UserTaskInstanceDesc> tasks = instance.getActiveTasks();
assertNotNull(tasks);
assertEquals(1, tasks.size());
UserTaskInstanceDesc activeTask = tasks.get(0);
assertNotNull(activeTask);
assertEquals(Status.Reserved.name(), activeTask.getStatus());
assertEquals(instance.getId(), activeTask.getProcessInstanceId());
assertEquals(instance.getProcessId(), activeTask.getProcessId());
assertEquals("Write a Document", activeTask.getName());
assertEquals("salaboy", activeTask.getActualOwner());
assertEquals(deploymentUnit.getIdentifier(), activeTask.getDeploymentId());
processService.abortProcessInstance(processInstanceId);
instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
processInstanceId = null;
assertNull(instance);
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceImplTest method testUpdateTaskPermissionDenied.
@Test
public void testUpdateTaskPermissionDenied() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals("Write a Document", task.getName());
try {
((org.jbpm.kie.services.impl.model.UserTaskInstanceDesc) task).setName("updated");
userTaskService.updateTask(taskId, "john", task, null, null);
fail("John is not admin nor potential owner");
} catch (PermissionDeniedException e) {
// expected
}
task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Reserved.toString(), task.getStatus());
assertEquals("Write a Document", task.getName());
assertEquals(9, task.getPriority().intValue());
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceImplTest method testSuspendAndResume.
@Test
public void testSuspendAndResume() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
userTaskService.suspend(taskId, "salaboy");
UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Suspended.toString(), task.getStatus());
userTaskService.resume(taskId, "salaboy");
task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Reserved.toString(), task.getStatus());
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceImplTest method testCompleteAutoProgress.
@Test
public void testCompleteAutoProgress() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
userTaskService.release(taskId, "salaboy");
Map<String, Object> results = new HashMap<String, Object>();
results.put("Result", "some document data");
// claim, start, and complete the task
userTaskService.completeAutoProgress(taskId, "salaboy", results);
UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Completed.toString(), task.getStatus());
}
Aggregations