Search in sources :

Example 11 with QueryContext

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

the class EGetProcessInstanceTest method getProcessInstancesByProcessDefinition.

@Test()
public void getProcessInstancesByProcessDefinition() {
    startProcess("org.jboss.qa.bpms.HumanTask", new HashMap<>(), 3);
    startProcess("org.jboss.qa.bpms.HumanTaskWithOwnType", new HashMap<>(), 5);
    // Please note that this list contains all instances (RUNNING/COMPLETED/ABORTED) of the
    // org.jboss.qa.bpms.HumanTask process definition. To make it contains all our instances
    // we must filter through it first. See enhancement request BZ-1179004 for more detail.
    QueryContext queryContext = new QueryContext(0, Integer.MAX_VALUE, "log.status", true);
    List<ProcessInstanceDesc> allList = ejb.getProcessInstancesByProcessDefinition("org.jboss.qa.bpms.HumanTask", queryContext);
    // Let's find our instances. We expect to find exactly 3 active instances. The exact number
    // is ensured by the RemoteEjbClient.abortAllProcesses() method.
    List<ProcessInstanceDesc> foundList = new ArrayList<>();
    for (ProcessInstanceDesc processInstanceDesc : allList) {
        if (processInstanceDesc.getState() == ProcessInstance.STATE_ACTIVE) {
            foundList.add(processInstanceDesc);
        }
    }
    Assertions.assertThat(foundList).hasSize(3);
    for (ProcessInstanceDesc pid : foundList) {
        Assertions.assertThat(pid.getProcessName()).isIn("HumanTask");
    }
}
Also used : ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.internal.query.QueryContext) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Aggregations

QueryContext (org.kie.internal.query.QueryContext)11 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)5 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)5 RemoteEjbTest (org.jbpm.remote.ejb.test.RemoteEjbTest)4 AbstractRuntimeEJBServicesTest (org.jbpm.test.container.AbstractRuntimeEJBServicesTest)3 HashMap (java.util.HashMap)2 VariableDesc (org.jbpm.services.api.model.VariableDesc)2 UserTransaction (javax.transaction.UserTransaction)1 EJBClient (org.jbpm.remote.ejb.test.client.EJBClient)1 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)1 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)1 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)1 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)1 AbstractEJBServicesTest (org.jbpm.test.container.AbstractEJBServicesTest)1