Search in sources :

Example 66 with UserTaskInstanceDesc

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());
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 67 with UserTaskInstanceDesc

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);
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 68 with UserTaskInstanceDesc

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());
}
Also used : PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 69 with UserTaskInstanceDesc

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());
}
Also used : UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 70 with UserTaskInstanceDesc

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());
}
Also used : HashMap(java.util.HashMap) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)118 Test (org.junit.Test)67 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)36 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)35 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)35 InternalTaskService (org.kie.internal.task.api.InternalTaskService)35 UserTaskService (org.jbpm.services.api.UserTaskService)34 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)34 TaskService (org.kie.api.task.TaskService)34 HashMap (java.util.HashMap)23 QueryContext (org.kie.api.runtime.query.QueryContext)22 ArrayList (java.util.ArrayList)18 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)16 PermissionDeniedException (org.jbpm.services.task.exception.PermissionDeniedException)16 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)15 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)11 QueryDefinition (org.jbpm.services.api.query.model.QueryDefinition)9 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)7 CorrelationKey (org.kie.internal.process.CorrelationKey)7 AdvancedQueryContext (org.kie.api.runtime.query.AdvancedQueryContext)6