Search in sources :

Example 81 with ProcessInstanceDesc

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

the class RuntimeDataServiceEJBIntegrationTest method testGetProcessInstancesByState.

@Test
public void testGetProcessInstancesByState() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    List<Integer> states = new ArrayList<Integer>();
    // search for aborted only
    states.add(3);
    instances = runtimeDataService.getProcessInstances(states, null, new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    instances = runtimeDataService.getProcessInstances(states, null, new QueryContext());
    assertNotNull(instances);
    assertEquals(1, instances.size());
    assertEquals(3, (int) instances.iterator().next().getState());
}
Also used : ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) Test(org.junit.Test)

Example 82 with ProcessInstanceDesc

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

the class RuntimeDataServiceEJBIntegrationTest method testGetProcessInstancesByProcessNameAndStateAndInitiator.

@Test
public void testGetProcessInstancesByProcessNameAndStateAndInitiator() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    List<Integer> states = new ArrayList<Integer>();
    // search for active only
    states.add(1);
    instances = runtimeDataService.getProcessInstancesByProcessName(states, "humanTaskSample", "anonymous", new QueryContext());
    assertNotNull(instances);
    assertEquals(1, instances.size());
    assertEquals(1, (int) instances.iterator().next().getState());
    instances = runtimeDataService.getProcessInstancesByProcessName(states, "humanTaskSample", "wrongUser", new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    instances = runtimeDataService.getProcessInstancesByProcessName(states, "humanTaskSample", "anonymous", new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
}
Also used : ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) Test(org.junit.Test)

Example 83 with ProcessInstanceDesc

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

the class RuntimeDataServiceEJBIntegrationTest method testGetTasksAssignedAsPotentialOwnerByStatusPagingAndFiltering.

@Test
public void testGetTasksAssignedAsPotentialOwnerByStatusPagingAndFiltering() {
    List<Long> processInstanceIds = new ArrayList<Long>();
    for (int i = 0; i < 10; i++) {
        processInstanceIds.add(processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument"));
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("processInstanceId", processInstanceIds);
    QueryFilter qf = new QueryFilter("t.taskData.processInstanceId in (:processInstanceId)", params, "t.id", false);
    qf.setOffset(0);
    qf.setCount(5);
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Ready);
    statuses.add(Status.Reserved);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", statuses, qf);
    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) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test)

Example 84 with ProcessInstanceDesc

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

the class RuntimeDataServiceEJBIntegrationTest method testGetProcessInstancesByProcessIdAndStateAndInitiator.

@Test
public void testGetProcessInstancesByProcessIdAndStateAndInitiator() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    List<Integer> states = new ArrayList<Integer>();
    // search for active only
    states.add(1);
    instances = runtimeDataService.getProcessInstancesByProcessId(states, "org.jbpm.writedocument", "anonymous", new QueryContext());
    assertNotNull(instances);
    assertEquals(1, instances.size());
    assertEquals(1, (int) instances.iterator().next().getState());
    instances = runtimeDataService.getProcessInstancesByProcessId(states, "org.jbpm.writedocument", "wrongUser", new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    instances = runtimeDataService.getProcessInstancesByProcessId(states, "org.jbpm.writedocument", "anonymous", new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
}
Also used : ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) Test(org.junit.Test)

Example 85 with ProcessInstanceDesc

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

the class RuntimeDataServiceEJBIntegrationTest method testGetProcessInstancesByProcessId.

@Test
public void testGetProcessInstancesByProcessId() {
    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.getProcessInstancesByProcessDefinition("org.jbpm.writedocument", new QueryContext());
    assertNotNull(instances);
    assertEquals(1, instances.size());
    ProcessInstanceDesc instance = instances.iterator().next();
    assertEquals(1, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    instances = runtimeDataService.getProcessInstancesByProcessDefinition("org.jbpm.writedocument", new QueryContext());
    assertNotNull(instances);
    assertEquals(1, instances.size());
    instance = instances.iterator().next();
    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) Test(org.junit.Test)

Aggregations

ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)198 Test (org.junit.Test)147 QueryContext (org.kie.api.runtime.query.QueryContext)123 ArrayList (java.util.ArrayList)75 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)57 HashMap (java.util.HashMap)32 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)25 TaskSummary (org.kie.api.task.model.TaskSummary)25 QueryFilter (org.kie.internal.query.QueryFilter)23 RemoteEjbTest (org.jbpm.remote.ejb.test.RemoteEjbTest)17 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)16 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)16 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)15 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)12 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)12 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)12 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)11 CorrelationKey (org.kie.internal.process.CorrelationKey)11 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)9 List (java.util.List)7