use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class EProcessHistoryTest method testNodeInstanceLogs.
@Test
public void testNodeInstanceLogs() {
long pid = startProcess(ProcessDefinitions.SCRIPT_TASK);
List<NodeInstanceDesc> logs = ejb.getProcessInstanceFullHistory(pid);
Assertions.assertThat(logs.size()).isEqualTo(6);
String[] expected = { "_A3185DDF-23A7-48B7-A2FE-7C0FE39F6691", "_3C8F4385-5348-479C-83EE-0C2DC2004F1A", "_DC07735C-FA99-414C-AEAC-9F4CE0CF24F9", "_DC07735C-FA99-414C-AEAC-9F4CE0CF24F9", "_3C8F4385-5348-479C-83EE-0C2DC2004F1A", "_A3185DDF-23A7-48B7-A2FE-7C0FE39F6691" };
for (int i = 0; i < logs.size(); ++i) {
NodeInstanceDesc node = logs.get(i);
Assertions.assertThat(node.getNodeId()).isEqualTo(expected[i]);
}
}
use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class EGetNodeInstanceTest method getNodeInstanceForWorkItem.
@Test()
public void getNodeInstanceForWorkItem() {
Long pid = ejb.startProcess("org.jboss.qa.bpms.HumanTask");
Long workItemId = null;
List<NodeInstanceDesc> nodeList = ejb.getProcessInstanceHistoryActive(pid, new QueryContext());
for (NodeInstanceDesc node : nodeList) {
if (node.getName().equals("Hello")) {
workItemId = node.getWorkItemId();
}
}
if (workItemId == null) {
throw new RuntimeException("Work item Id not found.");
}
NodeInstanceDesc nodeDesc = ejb.getNodeInstanceForWorkItem(workItemId);
Assertions.assertThat(nodeDesc).isNotNull();
Assertions.assertThat(nodeDesc.getDeploymentId()).isEqualTo(TestKjars.INTEGRATION.getGav());
Assertions.assertThat(nodeDesc.getProcessInstanceId()).isEqualTo(pid);
Assertions.assertThat(nodeDesc.getNodeId()).isEqualTo("_E4906EEE-6F73-4A8A-9E8E-E046EE35C10F");
Assertions.assertThat(nodeDesc.getName()).isEqualTo("Hello");
Assertions.assertThat(nodeDesc.getNodeType()).isEqualTo("HumanTaskNode");
Assertions.assertThat(nodeDesc.isCompleted()).isFalse();
}
use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class ProcessServiceImplWithDeploymentIdTest 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(deploymentUnit.getIdentifier(), 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(deploymentUnit.getIdentifier(), 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(deploymentUnit.getIdentifier(), processInstanceId);
pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNull(pi);
}
use of org.jbpm.services.api.model.NodeInstanceDesc in project jbpm by kiegroup.
the class ProcessServiceImplTest method testStartProcessAndCompleteWorkItemAfterDeactivation.
@Test
public void testStartProcessAndCompleteWorkItemAfterDeactivation() {
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);
deploymentService.deactivate(deploymentUnit.getIdentifier());
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 testStartProcessAndGetWorkItem.
@Test
public void testStartProcessAndGetWorkItem() {
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());
WorkItem wi = processService.getWorkItem(activeNodes.iterator().next().getWorkItemId());
assertNotNull(wi);
assertEquals("Human Task", wi.getName());
assertEquals("Write a Document", wi.getParameter("NodeName"));
processService.abortProcessInstance(processInstanceId);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
Aggregations