use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessInstanceById.
@Test
public void testGetProcessInstanceById() {
Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstanceDesc instance = runtimeDataService.getProcessInstanceById(processInstanceId);
assertNotNull(instance);
assertEquals(1, (int) instance.getState());
assertEquals("org.jbpm.writedocument", instance.getProcessId());
List<UserTaskInstanceDesc> tasks = instance.getActiveTasks();
assertNotNull(tasks);
assertEquals(1, tasks.size());
UserTaskInstanceDesc activeTask = tasks.get(0);
assertNotNull(activeTask);
assertEquals(Status.Reserved.name(), activeTask.getStatus());
assertEquals(instance.getId(), activeTask.getProcessInstanceId());
assertEquals(instance.getProcessId(), activeTask.getProcessId());
assertEquals("Write a Document", activeTask.getName());
assertEquals("salaboy", activeTask.getActualOwner());
assertEquals(deploymentUnit.getIdentifier(), activeTask.getDeploymentId());
processService.abortProcessInstance(processInstanceId);
instance = runtimeDataService.getProcessInstanceById(processInstanceId);
processInstanceId = null;
assertNotNull(instance);
assertEquals(3, (int) instance.getState());
assertEquals("org.jbpm.writedocument", instance.getProcessId());
}
use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessInstancesByVariableAndValue.
@Test
public void testGetProcessInstancesByVariableAndValue() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("approval_document", "initial content");
params.put("approval_reviewComment", "not yet reviewed");
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
assertNotNull(processInstanceId);
Collection<ProcessInstanceDesc> processInstanceLogs = runtimeDataService.getProcessInstancesByVariableAndValue("approval_document", "initial content", null, new QueryContext());
assertNotNull(processInstanceLogs);
assertEquals(1, processInstanceLogs.size());
processService.setProcessVariable(processInstanceId, "approval_document", "updated content");
processInstanceLogs = runtimeDataService.getProcessInstancesByVariableAndValue("approval_document", "initial content", null, new QueryContext());
assertNotNull(processInstanceLogs);
assertEquals(0, processInstanceLogs.size());
processInstanceLogs = runtimeDataService.getProcessInstancesByVariableAndValue("approval_document", "updated content", null, new QueryContext());
assertNotNull(processInstanceLogs);
assertEquals(1, processInstanceLogs.size());
processInstanceLogs = runtimeDataService.getProcessInstancesByVariableAndValue("approval_document", "updated%", null, new QueryContext());
assertNotNull(processInstanceLogs);
assertEquals(1, processInstanceLogs.size());
processInstanceLogs = runtimeDataService.getProcessInstancesByVariableAndValue("approval_reviewComment", "not yet%", null, new QueryContext());
assertNotNull(processInstanceLogs);
assertEquals(1, processInstanceLogs.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImplTest method testUpdateTimerRelative.
@Test(timeout = 10000)
public void testUpdateTimerRelative() throws Exception {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "IntermediateCatchEvent");
assertNotNull(processInstanceId);
long scheduleTime = System.currentTimeMillis();
Collection<NodeInstanceDesc> activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstanceDesc active = activeNodes.iterator().next();
assertEquals("timer", active.getName());
Collection<TimerInstance> timers = processAdminService.getTimerInstances(processInstanceId);
assertNotNull(timers);
assertEquals(1, timers.size());
TimerInstance timer = timers.iterator().next();
assertNotNull(timer.getActivationTime());
assertNotNull(timer.getDelay());
assertNotNull(timer.getNextFireTime());
assertNotNull(timer.getProcessInstanceId());
assertNotNull(timer.getSessionId());
assertNotNull(timer.getTimerId());
assertNotNull(timer.getTimerName());
// thread sleep to test the different in the time timer spent after upgrade
// not to wait for any job to be done
Thread.sleep(1000);
processAdminService.updateTimerRelative(processInstanceId, timer.getTimerId(), 3, 0, 0);
CountDownListenerFactory.getExisting("processAdminService").waitTillCompleted();
long fireTime = System.currentTimeMillis();
// since the update of timer was relative (to current time) then it must wait at least 3 secs
long expirationTime = fireTime - scheduleTime;
assertTrue(expirationTime > 3000);
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
assertEquals(ProcessInstance.STATE_COMPLETED, pi.getState().intValue());
processInstanceId = null;
}
use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImplTest method testTrigerLastActionNode.
@Test
public void testTrigerLastActionNode() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
Collection<NodeInstanceDesc> activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstanceDesc active = activeNodes.iterator().next();
assertEquals("Write a Document", active.getName());
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(1, tasks.size());
Collection<ProcessNode> processNodes = processAdminService.getProcessNodes(processInstanceId);
ProcessNode writeDocNode = processNodes.stream().filter(pn -> pn.getNodeName().equals("Report")).findFirst().orElse(null);
processAdminService.triggerNode(processInstanceId, writeDocNode.getNodeId());
activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(0, activeNodes.size());
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(0, tasks.size());
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
assertEquals(ProcessInstance.STATE_COMPLETED, pi.getState().intValue());
processInstanceId = null;
}
use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.
the class QueryServiceEJBIntegrationTest method testGetProcessInstancesByState.
@Test
public void testGetProcessInstancesByState() {
query = new SqlQueryDefinition("getAllProcessInstances", "java:jboss/datasources/ExampleDS");
query.setExpression("select * from processinstancelog");
queryService.registerQuery(query);
Collection<ProcessInstanceDesc> instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
// search for aborted only
instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_STATUS, 3));
assertNotNull(instances);
assertEquals(0, instances.size());
// aborted and active
instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_STATUS, 3, 1));
assertNotNull(instances);
assertEquals(1, instances.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
// aborted only
instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_STATUS, 3));
assertNotNull(instances);
assertEquals(1, instances.size());
assertEquals(3, (int) instances.iterator().next().getState());
}
Aggregations