Search in sources :

Example 31 with UserTaskInstanceDesc

use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.

the class UserTaskServiceImplTest method testSkip.

@Test
public void testSkip() {
    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.skip(taskId, "Administrator");
    UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
    assertNotNull(task);
    assertEquals(Status.Obsolete.toString(), task.getStatus());
}
Also used : UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 32 with UserTaskInstanceDesc

use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.

the class UserTaskServiceImplTest method testSetExpirationDate.

@Test
public void testSetExpirationDate() throws Exception {
    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(Status.Reserved.toString(), task.getStatus());
    Date origDueDate = task.getDueDate();
    assertNull(origDueDate);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    userTaskService.setExpirationDate(taskId, sdf.parse("2013-12-31"));
    task = runtimeDataService.getTaskById(taskId);
    assertNotNull(task);
    assertEquals(Status.Reserved.toString(), task.getStatus());
    assertEquals("2013-12-31", sdf.format(task.getDueDate()));
}
Also used : UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 33 with UserTaskInstanceDesc

use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.

the class UserTaskServiceImplTest method testStartAndComplete.

@Test
public void testStartAndComplete() {
    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.start(taskId, "salaboy");
    UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
    assertNotNull(task);
    assertEquals(Status.InProgress.toString(), task.getStatus());
    Map<String, Object> results = new HashMap<String, Object>();
    results.put("Result", "some document data");
    userTaskService.complete(taskId, "salaboy", results);
    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)

Example 34 with UserTaskInstanceDesc

use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.

the class UserTaskServiceImplTest method testUpdateTaskWithData.

@Test
public void testUpdateTaskWithData() {
    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(Status.Reserved.toString(), task.getStatus());
    assertEquals("Write a Document", task.getName());
    assertEquals(9, task.getPriority().intValue());
    Map<String, Object> inputs = userTaskService.getTaskInputContentByTaskId(taskId);
    assertEquals(6, inputs.size());
    Map<String, Object> outputs = userTaskService.getTaskOutputContentByTaskId(taskId);
    assertEquals(0, outputs.size());
    ((org.jbpm.kie.services.impl.model.UserTaskInstanceDesc) task).setName("updated");
    ((org.jbpm.kie.services.impl.model.UserTaskInstanceDesc) task).setPriority(5);
    Map<String, Object> updatedInputs = new HashMap<>();
    updatedInputs.put("new task input", "test");
    Map<String, Object> updatedOutputs = new HashMap<>();
    updatedOutputs.put("new task output", "reviewed");
    userTaskService.updateTask(taskId, "salaboy", task, updatedInputs, updatedOutputs);
    task = runtimeDataService.getTaskById(taskId);
    assertNotNull(task);
    assertEquals(Status.Reserved.toString(), task.getStatus());
    assertEquals("updated", task.getName());
    assertEquals(5, task.getPriority().intValue());
    inputs = userTaskService.getTaskInputContentByTaskId(taskId);
    assertEquals("test", inputs.get("new task input"));
    outputs = userTaskService.getTaskOutputContentByTaskId(taskId);
    assertEquals("reviewed", outputs.get("new task output"));
}
Also used : HashMap(java.util.HashMap) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 35 with UserTaskInstanceDesc

use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.

the class UserTaskServiceImplTest method testStartAndFail.

@Test
public void testStartAndFail() {
    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.start(taskId, "salaboy");
    UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
    assertNotNull(task);
    assertEquals(Status.InProgress.toString(), task.getStatus());
    userTaskService.fail(taskId, "Administrator", new HashMap<String, Object>());
    task = runtimeDataService.getTaskById(taskId);
    assertNotNull(task);
    assertEquals(Status.Failed.toString(), task.getStatus());
}
Also used : 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