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());
}
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());
}
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());
}
}
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());
}
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());
}
Aggregations