use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testTasksByStatusByProcessInstanceIdPagingAndFiltering.
@Test
public void testTasksByStatusByProcessInstanceIdPagingAndFiltering() {
Long pid = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
List<Status> statuses = new ArrayList<Status>();
statuses.add(Status.Ready);
statuses.add(Status.Reserved);
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", statuses, new QueryFilter(0, 5));
assertNotNull(tasks);
assertEquals(1, tasks.size());
long taskId = tasks.get(0).getId();
userTaskService.start(taskId, "salaboy");
userTaskService.complete(taskId, "salaboy", null);
Map<String, Object> params = new HashMap<String, Object>();
params.put("name", "Review Document");
QueryFilter qf = new QueryFilter("t.name = :name", params, "t.id", false);
qf.setOffset(0);
qf.setCount(5);
tasks = runtimeDataService.getTasksByStatusByProcessInstanceId(pid, statuses, qf);
assertNotNull(tasks);
assertEquals(1, tasks.size());
TaskSummary userTask = tasks.get(0);
assertNotNull(userTask);
assertEquals("Review Document", userTask.getName());
tasks = runtimeDataService.getTasksByStatusByProcessInstanceId(pid, statuses, new QueryFilter(0, 5));
assertNotNull(tasks);
assertEquals(2, tasks.size());
Collection<ProcessInstanceDesc> activeProcesses = runtimeDataService.getProcessInstances(new QueryContext(0, 20));
for (ProcessInstanceDesc pi : activeProcesses) {
processService.abortProcessInstance(pi.getId());
}
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessInstancesByDeploymentIdAndState.
@Test
public void testGetProcessInstancesByDeploymentIdAndState() {
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.getProcessInstancesByDeploymentId(deploymentUnit.getIdentifier(), states, new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
String origVer = deploymentUnit.getVersion();
deploymentUnit.setVersion("LATEST");
instances = runtimeDataService.getProcessInstancesByDeploymentId(deploymentUnit.getIdentifier(), states, new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
instances = runtimeDataService.getProcessInstancesByDeploymentId(deploymentUnit.getIdentifier(), states, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
assertEquals(3, (int) instances.iterator().next().getState());
deploymentUnit.setVersion(origVer);
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessInstancesByStateAndInitiator.
@Test
public void testGetProcessInstancesByStateAndInitiator() {
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.getProcessInstances(states, correctUser, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
assertEquals(1, (int) instances.iterator().next().getState());
instances = runtimeDataService.getProcessInstances(states, wrongUser, new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
instances = runtimeDataService.getProcessInstances(states, correctUser, new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessByFilter.
@Test
public void testGetProcessByFilter() {
Collection<ProcessDefinition> definitions = runtimeDataService.getProcessesByFilter("org.jbpm", new QueryContext());
assertNotNull(definitions);
assertEquals(2, definitions.size());
List<String> expectedProcessIds = new ArrayList<String>();
expectedProcessIds.add("org.jbpm.writedocument.empty");
expectedProcessIds.add("org.jbpm.writedocument");
for (ProcessDefinition def : definitions) {
assertTrue(expectedProcessIds.contains(def.getId()));
}
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcesses.
@Test
public void testGetProcesses() {
Collection<ProcessDefinition> definitions = runtimeDataService.getProcesses(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()));
}
}
Aggregations