use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class ProcessServiceImplTest method testStartProcessAndGetWorkItems.
@Test
public void testStartProcessAndGetWorkItems() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNotNull(pi);
Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
assertEquals("Write a Document", activeNodes.iterator().next().getName());
List<WorkItem> wis = processService.getWorkItemByProcessInstance(processInstanceId);
assertNotNull(wis);
assertEquals(1, wis.size());
assertEquals("Human Task", wis.get(0).getName());
assertEquals("Write a Document", wis.get(0).getParameter("NodeName"));
processService.abortProcessInstance(processInstanceId);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class ProcessServiceImplTest method testStartProcessAndCompleteWorkItem.
@Test
public void testStartProcessAndCompleteWorkItem() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNotNull(pi);
Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
assertEquals("Write a Document", activeNodes.iterator().next().getName());
Map<String, Object> outcome = new HashMap<String, Object>();
outcome.put("Result", "here is my first document");
processService.completeWorkItem(activeNodes.iterator().next().getWorkItemId(), outcome);
activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(activeNodes);
assertEquals(2, activeNodes.size());
Object variableValue = processService.getProcessInstanceVariable(processInstanceId, "approval_document");
assertNotNull(variableValue);
assertTrue(variableValue instanceof String);
assertEquals("here is my first document", variableValue);
processService.abortProcessInstance(processInstanceId);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class ProcessServiceImplTest method testStartProcessAndAbortWorkItem.
@Test
public void testStartProcessAndAbortWorkItem() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNotNull(pi);
Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
assertEquals("Write a Document", activeNodes.iterator().next().getName());
processService.abortWorkItem(activeNodes.iterator().next().getWorkItemId());
activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(activeNodes);
assertEquals(2, activeNodes.size());
Object variableValue = processService.getProcessInstanceVariable(processInstanceId, "approval_document");
assertNull(variableValue);
processService.abortProcessInstance(processInstanceId);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
use of org.jbpm.services.api.model.NodeInstanceDesc 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.NodeInstanceDesc 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;
}
Aggregations