Search in sources :

Example 36 with UserTaskInstanceDesc

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

the class UserTaskServiceImplTest method testCompleteAutoProgressWrongDeploymentId.

@Test
public void testCompleteAutoProgressWrongDeploymentId() {
    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");
    assertThatExceptionOfType(TaskNotFoundException.class).isThrownBy(() -> {
        userTaskService.completeAutoProgress("wrong-one", taskId, "salaboy", results);
    }).withMessageContaining("Task with id " + taskId + " is not associated with wrong-one");
    UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
    assertNotNull(task);
    assertEquals(Status.Ready.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 37 with UserTaskInstanceDesc

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

the class UserTaskServiceImplTest method testSetDescription.

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

Example 38 with UserTaskInstanceDesc

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

the class QueryServiceImplTest method testGetFilteredTaskInstancesAsBA.

@Test
public void testGetFilteredTaskInstancesAsBA() {
    // let's grant managers role so process can be started
    List<String> roles = new ArrayList<String>();
    roles.add("managers");
    identityProvider.setRoles(roles);
    query = new SqlQueryDefinition("getTaskInstancesAdmin", dataSourceJNDIname, Target.FILTERED_BA_TASK);
    query.setExpression("select ti.activationTime, ti.actualOwner, ti.createdBy, ti.createdOn, ti.deploymentId, " + "ti.description, ti.dueDate, ti.name, ti.parentId, ti.priority, ti.processId, ti.processInstanceId, " + "ti.processSessionId, ti.status, ti.taskId, ti.workItemId, oe.id " + "from  AuditTaskImpl ti left join PeopleAssignments_BAs ba on ti.taskId = ba.task_id left join " + "OrganizationalEntity oe on ba.entity_id = oe.id");
    queryService.registerQuery(query);
    List<QueryDefinition> queries = queryService.getQueries(new QueryContext());
    assertNotNull(queries);
    assertEquals(1, queries.size());
    QueryDefinition registeredQuery = queryService.getQuery(query.getName());
    assertNotNull(registeredQuery);
    assertEquals(query.getName(), registeredQuery.getName());
    assertEquals(query.getSource(), registeredQuery.getSource());
    assertEquals(query.getExpression(), registeredQuery.getExpression());
    assertEquals(query.getTarget(), registeredQuery.getTarget());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("approval_document", "initial content");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
    assertNotNull(processInstanceId);
    List<UserTaskInstanceDesc> taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext());
    assertNotNull(taskInstanceLogs);
    assertEquals(0, taskInstanceLogs.size());
    identityProvider.setName("Administrator");
    taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext(), QueryParam.groupBy(COLUMN_TASKID));
    assertNotNull(taskInstanceLogs);
    assertEquals(1, taskInstanceLogs.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : SqlQueryDefinition(org.jbpm.kie.services.impl.query.SqlQueryDefinition) QueryDefinition(org.jbpm.services.api.query.model.QueryDefinition) HashMap(java.util.HashMap) SqlQueryDefinition(org.jbpm.kie.services.impl.query.SqlQueryDefinition) ArrayList(java.util.ArrayList) AdvancedQueryContext(org.kie.api.runtime.query.AdvancedQueryContext) 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 39 with UserTaskInstanceDesc

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

the class QueryServiceImplTest method testGetTaskInstancesAsBA.

@Test
public void testGetTaskInstancesAsBA() {
    query = new SqlQueryDefinition("getBATaskInstances", dataSourceJNDIname, Target.BA_TASK);
    query.setExpression("select ti.activationTime, ti.actualOwner, ti.createdBy, ti.createdOn, ti.deploymentId, " + "ti.description, ti.dueDate, ti.name, ti.parentId, ti.priority, ti.processId, ti.processInstanceId, " + "ti.processSessionId, ti.status, ti.taskId, ti.workItemId, oe.id " + "from AuditTaskImpl ti," + "PeopleAssignments_BAs bas, " + "OrganizationalEntity oe " + "where ti.taskId = bas.task_id and bas.entity_id = oe.id ");
    queryService.registerQuery(query);
    List<QueryDefinition> queries = queryService.getQueries(new QueryContext());
    assertNotNull(queries);
    assertEquals(1, queries.size());
    QueryDefinition registeredQuery = queries.get(0);
    assertNotNull(registeredQuery);
    assertEquals(query.getName(), registeredQuery.getName());
    assertEquals(query.getSource(), registeredQuery.getSource());
    assertEquals(query.getExpression(), registeredQuery.getExpression());
    assertEquals(query.getTarget(), registeredQuery.getTarget());
    registeredQuery = queryService.getQuery(query.getName());
    assertNotNull(registeredQuery);
    assertEquals(query.getName(), registeredQuery.getName());
    assertEquals(query.getSource(), registeredQuery.getSource());
    assertEquals(query.getExpression(), registeredQuery.getExpression());
    assertEquals(query.getTarget(), registeredQuery.getTarget());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("approval_document", "initial content");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
    assertNotNull(processInstanceId);
    List<UserTaskInstanceDesc> taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext(), QueryParam.groupBy(COLUMN_TASKID));
    assertNotNull(taskInstanceLogs);
    assertEquals(0, taskInstanceLogs.size());
    identityProvider.setName("Administrator");
    taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext(), QueryParam.groupBy(COLUMN_TASKID));
    assertNotNull(taskInstanceLogs);
    assertEquals(1, taskInstanceLogs.size());
    identityProvider.setName("salaboy");
    identityProvider.setRoles(Arrays.asList("Administrators"));
    taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext(), QueryParam.groupBy(COLUMN_TASKID));
    assertNotNull(taskInstanceLogs);
    assertEquals(1, taskInstanceLogs.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : SqlQueryDefinition(org.jbpm.kie.services.impl.query.SqlQueryDefinition) QueryDefinition(org.jbpm.services.api.query.model.QueryDefinition) HashMap(java.util.HashMap) SqlQueryDefinition(org.jbpm.kie.services.impl.query.SqlQueryDefinition) AdvancedQueryContext(org.kie.api.runtime.query.AdvancedQueryContext) 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 40 with UserTaskInstanceDesc

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

the class RuntimeDataServiceImplTest method testGetProcessInstanceById.

@Test
public void testGetProcessInstanceById() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstanceDesc instance = runtimeDataService.getProcessInstanceById(processInstanceId);
    assertNotNull(instance);
    assertEquals(1, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    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.getProcessInstanceById(processInstanceId);
    processInstanceId = null;
    assertNotNull(instance);
    assertEquals(3, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
}
Also used : 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)

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