use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetNodeInstanceForWorkItem.
@Test
public void testGetNodeInstanceForWorkItem() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance instance = processService.getProcessInstance(processInstanceId);
assertNotNull(instance);
Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstance node = activeNodes.iterator().next();
assertNotNull(node);
assertTrue(node instanceof WorkItemNodeInstance);
Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
assertNotNull(workItemId);
NodeInstanceDesc desc = runtimeDataService.getNodeInstanceForWorkItem(workItemId);
assertNotNull(desc);
assertEquals(processInstanceId, desc.getProcessInstanceId());
assertEquals("Write a Document", desc.getName());
assertEquals("HumanTaskNode", desc.getNodeType());
}
use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessInstanceHistory.
@Test
public void testGetProcessInstanceHistory() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
// get active nodes as history view
Collection<NodeInstanceDesc> instances = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
// get completed nodes as history view
instances = runtimeDataService.getProcessInstanceHistoryCompleted(processInstanceId, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
// get both active and completed nodes as history view
instances = runtimeDataService.getProcessInstanceFullHistory(processInstanceId, new QueryContext());
assertNotNull(instances);
assertEquals(3, instances.size());
// get nodes filtered by type - start
instances = runtimeDataService.getProcessInstanceFullHistoryByType(processInstanceId, EntryType.START, new QueryContext());
assertNotNull(instances);
assertEquals(2, instances.size());
// get nodes filtered by type - end
instances = runtimeDataService.getProcessInstanceFullHistoryByType(processInstanceId, EntryType.END, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
}
use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImplTest method testCancelAndTriger.
@Test
public void testCancelAndTriger() {
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());
processAdminService.cancelNodeInstance(processInstanceId, active.getId());
activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(0, activeNodes.size());
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(0, tasks.size());
Collection<ProcessNode> processNodes = processAdminService.getProcessNodes(processInstanceId);
ProcessNode writeDocNode = processNodes.stream().filter(pn -> pn.getNodeName().equals(active.getName())).findFirst().orElse(null);
processAdminService.triggerNode(processInstanceId, writeDocNode.getNodeId());
activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(1, tasks.size());
}
use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImplTest method testCancelAndTrigerAnotherNode.
@Test
public void testCancelAndTrigerAnotherNode() {
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());
processAdminService.cancelNodeInstance(processInstanceId, active.getId());
activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(0, activeNodes.size());
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(0, 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.NodeInstanceDesc in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImplTest method testUpdateTimer.
@Test(timeout = 10000)
public void testUpdateTimer() 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.updateTimer(processInstanceId, timer.getTimerId(), 3, 0, 0);
CountDownListenerFactory.getExisting("processAdminService").waitTillCompleted();
long fireTime = System.currentTimeMillis();
long expirationTime = fireTime - scheduleTime;
// since the update of timer was including time already spent (thread sleep above) then it must wait less than 4 secs
assertTrue(expirationTime < 4000);
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
assertEquals(ProcessInstance.STATE_COMPLETED, pi.getState().intValue());
processInstanceId = null;
}
Aggregations