use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceAdminServiceIntegrationTest method testCancelAndTrigger.
@Test
public void testCancelAndTrigger() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
Long processInstanceId = null;
try {
processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION, parameters);
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
List<NodeInstance> activeNodeInstances = processAdminClient.getActiveNodeInstances(CONTAINER_ID, processInstanceId);
assertNotNull(activeNodeInstances);
assertEquals(1, activeNodeInstances.size());
NodeInstance active = activeNodeInstances.get(0);
assertEquals("Evaluate items?", active.getName());
processAdminClient.cancelNodeInstance(CONTAINER_ID, processInstanceId, active.getId());
activeNodeInstances = processAdminClient.getActiveNodeInstances(CONTAINER_ID, processInstanceId);
assertNotNull(activeNodeInstances);
assertEquals(0, activeNodeInstances.size());
List<ProcessNode> processNodes = processAdminClient.getProcessNodes(CONTAINER_ID, processInstanceId);
ProcessNode first = processNodes.stream().filter(pn -> pn.getNodeName().equals("Evaluate items?")).findFirst().orElse(null);
assertNotNull(first);
processAdminClient.triggerNode(CONTAINER_ID, processInstanceId, first.getNodeId());
activeNodeInstances = processAdminClient.getActiveNodeInstances(CONTAINER_ID, processInstanceId);
assertNotNull(activeNodeInstances);
assertEquals(1, activeNodeInstances.size());
NodeInstance activeTriggered = activeNodeInstances.get(0);
assertEquals("Evaluate items?", activeTriggered.getName());
assertFalse(activeTriggered.getId().longValue() == active.getId().longValue());
} finally {
if (processInstanceId != null) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class CaseRuntimeDataServiceIntegrationTest method testCreateCaseWithCaseFileAndDynamicActivities.
@Test
public void testCreateCaseWithCaseFileAndDynamicActivities() {
String caseId = startUserTaskCase(USER_JOHN, USER_YODA);
assertNotNull(caseId);
assertTrue(caseId.startsWith(CASE_HR_ID_PREFIX));
List<NodeInstance> activeNodes = caseClient.getActiveNodes(CONTAINER_ID, caseId, 0, 10);
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstance activeNode = activeNodes.get(0);
assertNotNull(activeNode);
assertEquals("Hello1", activeNode.getName());
List<NodeInstance> completedNodes = caseClient.getCompletedNodes(CONTAINER_ID, caseId, 0, 10);
assertNotNull(completedNodes);
assertEquals(0, completedNodes.size());
List<ProcessInstance> instances = caseClient.getActiveProcessInstances(CONTAINER_ID, caseId, 0, 10);
assertNotNull(instances);
assertEquals(1, instances.size());
ProcessInstance pi = instances.get(0);
assertEquals(CASE_HR_DEF_ID, pi.getProcessId());
assertEquals(caseId, pi.getCorrelationKey());
Map<String, Object> parameters = new HashMap<>();
parameters.put("input", "text data");
caseClient.addDynamicUserTask(CONTAINER_ID, caseId, "dynamic task", "simple description", USER_YODA, null, parameters);
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
TaskSummary task = tasks.get(0);
assertEquals("dynamic task", task.getName());
assertEquals("simple description", task.getDescription());
assertEquals(Status.Reserved.toString(), task.getStatus());
assertEquals(USER_YODA, task.getActualOwner());
activeNodes = caseClient.getActiveNodes(CONTAINER_ID, caseId, 0, 10);
assertNotNull(activeNodes);
assertEquals(2, activeNodes.size());
List<String> nodeNames = activeNodes.stream().map(n -> n.getName()).collect(toList());
assertTrue(nodeNames.contains("[Dynamic] dynamic task"));
assertTrue(nodeNames.contains("Hello1"));
taskClient.completeAutoProgress(CONTAINER_ID, task.getId(), USER_YODA, null);
completedNodes = caseClient.getCompletedNodes(CONTAINER_ID, caseId, 0, 10);
assertNotNull(completedNodes);
assertEquals(1, completedNodes.size());
NodeInstance completedNode = completedNodes.get(0);
assertNotNull(completedNode);
assertEquals("[Dynamic] dynamic task", completedNode.getName());
caseClient.addDynamicSubProcess(CONTAINER_ID, caseId, "DataVerification", parameters);
instances = caseClient.getProcessInstances(CONTAINER_ID, caseId, Arrays.asList(1, 2, 3), 0, 10);
assertNotNull(instances);
assertEquals(2, instances.size());
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class CaseManagementRuntimeDataServiceBase method getCompletedNodes.
public NodeInstanceList getCompletedNodes(String containerId, String caseId, Integer page, Integer pageSize) {
Collection<NodeInstanceDesc> completedNodeInstances = caseRuntimeDataService.getCompletedNodesForCase(caseId, ConvertUtils.buildQueryContext(page, pageSize));
List<NodeInstance> completedNodes = ConvertUtils.transformNodeInstance(completedNodeInstances);
NodeInstanceList completedNodesList = new NodeInstanceList(completedNodes);
return completedNodesList;
}
Aggregations