Search in sources :

Example 71 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class RuntimeDataServiceImplTest method testGetProcessesByDeploymentId.

@Test
public void testGetProcessesByDeploymentId() {
    Collection<ProcessDefinition> definitions = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
    assertNotNull(definitions);
    assertEquals(5, definitions.size());
    List<String> expectedProcessIds = new ArrayList<String>();
    expectedProcessIds.add("org.jbpm.writedocument.empty");
    expectedProcessIds.add("org.jbpm.writedocument");
    expectedProcessIds.add("UserTask");
    expectedProcessIds.add("org.jboss.qa.bpms.HumanTask");
    expectedProcessIds.add("AdHocSubProcess");
    for (ProcessDefinition def : definitions) {
        assertTrue(expectedProcessIds.contains(def.getId()));
    }
    String origVer = deploymentUnit.getVersion();
    deploymentUnit.setVersion("LATEST");
    definitions = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
    assertNotNull(definitions);
    assertEquals(5, definitions.size());
    deploymentUnit.setVersion(origVer);
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 72 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class RuntimeDataServiceImplTest method testGetTasksByVariable.

@Test
public void testGetTasksByVariable() {
    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<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Ready);
    statuses.add(Status.Reserved);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", statuses, new QueryFilter());
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    String userId = "salaboy";
    String varName = "Comment";
    List<TaskSummary> tasksByVariable = runtimeDataService.getTasksByVariable(userId, varName, statuses, new QueryContext());
    assertNotNull(tasksByVariable);
    assertEquals(1, tasksByVariable.size());
    varName = "ReviewComment";
    tasksByVariable = runtimeDataService.getTasksByVariable(userId, varName, statuses, new QueryContext());
    assertNotNull(tasksByVariable);
    assertEquals(0, tasksByVariable.size());
    long taskId = tasks.get(0).getId();
    Map<String, Object> output = new HashMap<String, Object>();
    output.put("ReviewComment", "document reviewed");
    userTaskService.saveContent(taskId, output);
    tasksByVariable = runtimeDataService.getTasksByVariable(userId, varName, statuses, new QueryContext());
    assertNotNull(tasksByVariable);
    assertEquals(1, tasksByVariable.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : Status(org.kie.api.task.model.Status) QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 73 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class RuntimeDataServiceImplTest method testGetTasksAssignedAsPotentialOwnerSortedByAlias.

@Test
public void testGetTasksAssignedAsPotentialOwnerSortedByAlias() {
    List<Long> processInstanceIds = new ArrayList<Long>();
    for (int i = 0; i < 10; i++) {
        processInstanceIds.add(processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument"));
    }
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Ready);
    statuses.add(Status.Reserved);
    QueryFilter ctx = new QueryFilter(0, 5, "Status", true);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", statuses, ctx);
    assertNotNull(tasks);
    assertEquals(5, tasks.size());
    TaskSummary userTask = tasks.get(0);
    assertNotNull(userTask);
    assertEquals("Write a Document", userTask.getName());
    Collection<ProcessInstanceDesc> activeProcesses = runtimeDataService.getProcessInstances(new QueryContext(0, 20));
    for (ProcessInstanceDesc pi : activeProcesses) {
        processService.abortProcessInstance(pi.getId());
    }
}
Also used : Status(org.kie.api.task.model.Status) QueryFilter(org.kie.internal.query.QueryFilter) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 74 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class RuntimeDataServiceImplTest method testGetProcessesSortByProcessName.

@Test
public void testGetProcessesSortByProcessName() {
    Collection<ProcessDefinition> definitions = runtimeDataService.getProcesses(new QueryContext("ProcessName", true));
    assertNotNull(definitions);
    assertEquals(5, definitions.size());
    List<String> expectedProcessIds = new ArrayList<String>();
    expectedProcessIds.add("AdHoc SubProcess");
    expectedProcessIds.add("HumanTask");
    expectedProcessIds.add("User Task");
    expectedProcessIds.add("humanTaskSample");
    expectedProcessIds.add("humanTaskSample");
    int index = 0;
    for (ProcessDefinition def : definitions) {
        assertEquals(def.getName(), expectedProcessIds.get(index));
        index++;
    }
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 75 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class RuntimeDataServiceImplTest method testGetProcessInstances.

@Test
public void testGetProcessInstances() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(1, instances.size());
    assertEquals(1, (int) instances.iterator().next().getState());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    instances = runtimeDataService.getProcessInstances(new QueryContext("log.processName", false));
    assertNotNull(instances);
    assertEquals(1, instances.size());
    assertEquals(3, (int) instances.iterator().next().getState());
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

QueryContext (org.kie.api.runtime.query.QueryContext)315 Test (org.junit.Test)299 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)131 HashMap (java.util.HashMap)115 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)109 ArrayList (java.util.ArrayList)99 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)67 RequestInfo (org.kie.api.executor.RequestInfo)53 TaskSummary (org.kie.api.task.model.TaskSummary)53 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)51 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)49 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)45 CommandContext (org.kie.api.executor.CommandContext)39 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)37 UserImpl (org.jbpm.services.task.impl.model.UserImpl)37 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)36 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)34 QueryFilter (org.kie.internal.query.QueryFilter)30 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)29 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)29