use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class ProcessServiceIntegrationTest method testCallActivityProcess.
@Test
public void testCallActivityProcess() {
Map<String, Object> parameters = new HashMap<String, Object>();
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_CALL_EVALUATION, parameters);
try {
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
// Process instance is running and is active.
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE, processInstance.getState().intValue());
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
taskClient.completeAutoProgress(CONTAINER_ID, tasks.get(0).getId(), USER_YODA, null);
List<ProcessInstance> instances = processClient.findProcessInstancesByParent(CONTAINER_ID, processInstanceId, 0, 10);
assertEquals(1, instances.size());
ProcessInstance childInstance = instances.get(0);
assertNotNull(childInstance);
assertEquals(PROCESS_ID_EVALUATION, childInstance.getProcessId());
assertEquals(processInstanceId, childInstance.getParentId());
List<NodeInstance> activeNodes = queryClient.findActiveNodeInstances(processInstanceId, 0, 10);
assertEquals(1, activeNodes.size());
NodeInstance active = activeNodes.get(0);
assertEquals("Call Evaluation", active.getName());
assertEquals("SubProcessNode", active.getNodeType());
assertEquals(childInstance.getId(), active.getReferenceId());
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
// Process instance is now aborted.
processInstance = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ABORTED, processInstance.getState().intValue());
processInstance = processClient.getProcessInstance(CONTAINER_ID, childInstance.getId());
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ABORTED, processInstance.getState().intValue());
// no more active instances
instances = processClient.findProcessInstancesByParent(CONTAINER_ID, processInstanceId, 0, 10);
assertEquals(0, instances.size());
instances = processClient.findProcessInstancesByParent(CONTAINER_ID, processInstanceId, Arrays.asList(3), 0, 10);
assertEquals(1, instances.size());
} catch (Exception e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
fail(e.getMessage());
}
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class ProcessUserTaskServicesSecurityIntegrationTest method testNonAllowedUserCannotStartProcessFromNodeIdsWithCorrelationKey.
@Test
public void testNonAllowedUserCannotStartProcessFromNodeIdsWithCorrelationKey() throws Exception {
Map<String, Object> parameters = new HashMap<>();
Long processInstanceId = startProcessAsAdministrator(PROCESS_ID_USERTASK_SECURED);
try {
processClient.abortProcessInstance(CONTAINER_ID_SECURED, processInstanceId);
List<NodeInstance> list = this.processClient.findNodeInstancesByType(CONTAINER_ID_SECURED, processInstanceId, "ABORTED", 0, 10);
String[] nodeIds = list.stream().map(NodeInstance::getNodeId).toArray(String[]::new);
CorrelationKeyFactory correlationKeyFactory = KieInternalServices.Factory.get().newCorrelationKeyFactory();
CorrelationKey firstKey = correlationKeyFactory.newCorrelationKey("mysimlekey");
processInstanceId = null;
changeUser(USER_YODA);
assertClientException(() -> processClient.startProcessFromNodeIds(CONTAINER_ID_SECURED, PROCESS_ID_USERTASK_SECURED, firstKey, parameters, nodeIds), 403, String.format(NO_PERMISSION_MSG, USER_YODA));
} finally {
if (processInstanceId != null)
abortProcessAsAdministrator(processInstanceId);
changeUser(TestConfig.getUsername());
}
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class CaseManagementRuntimeDataServiceBase method getActiveNodes.
public NodeInstanceList getActiveNodes(String containerId, String caseId, Integer page, Integer pageSize) {
Collection<NodeInstanceDesc> activeNodeInstances = caseRuntimeDataService.getActiveNodesForCase(caseId, ConvertUtils.buildQueryContext(page, pageSize));
List<NodeInstance> activeNodes = ConvertUtils.transformNodeInstance(activeNodeInstances);
NodeInstanceList activeNodesList = new NodeInstanceList(activeNodes);
return activeNodesList;
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class CaseRuntimeDataServiceIntegrationTest method testGetCaseInstanceCarInsuranceClaimCaseWithData.
@Test
public void testGetCaseInstanceCarInsuranceClaimCaseWithData() {
String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId, true, true, true, true);
assertCarInsuranceCaseInstance(caseInstance, caseId, USER_YODA);
KieServerAssert.assertNullOrEmpty("Milestones should be empty.", caseInstance.getMilestones());
// Assert case file
assertNotNull(caseInstance.getCaseFile());
assertEquals("first case started", caseInstance.getCaseFile().getData().get("s"));
// Assert role assignments
assertNotNull(caseInstance.getRoleAssignments());
assertEquals(4, caseInstance.getRoleAssignments().size());
CaseRoleAssignment ownerRole = caseInstance.getRoleAssignments().get(0);
assertEquals("owner", ownerRole.getName());
assertEquals(1, ownerRole.getUsers().size());
assertEquals(USER_YODA, ownerRole.getUsers().get(0));
KieServerAssert.assertNullOrEmpty("Groups should be empty.", ownerRole.getGroups());
CaseRoleAssignment insuredRole = caseInstance.getRoleAssignments().get(1);
assertEquals("insured", insuredRole.getName());
assertEquals(1, insuredRole.getUsers().size());
assertEquals(USER_YODA, insuredRole.getUsers().get(0));
KieServerAssert.assertNullOrEmpty("Groups should be empty.", insuredRole.getGroups());
CaseRoleAssignment assessorRole = caseInstance.getRoleAssignments().get(2);
assertEquals("assessor", assessorRole.getName());
assertEquals(USER_YODA, assessorRole.getUsers().get(0));
KieServerAssert.assertNullOrEmpty("Groups should be empty.", assessorRole.getGroups());
CaseRoleAssignment insuranceRepresentativeRole = caseInstance.getRoleAssignments().get(3);
assertEquals("insuranceRepresentative", insuranceRepresentativeRole.getName());
assertEquals(1, insuranceRepresentativeRole.getUsers().size());
assertEquals(USER_JOHN, insuranceRepresentativeRole.getUsers().get(0));
KieServerAssert.assertNullOrEmpty("Groups should be empty.", insuranceRepresentativeRole.getGroups());
// Assert stages
assertNotNull(caseInstance.getStages());
assertEquals(1, caseInstance.getStages().size());
CaseStage stage = caseInstance.getStages().get(0);
assertNotNull(stage.getIdentifier());
assertEquals("Build claim report", stage.getName());
assertEquals("Active", stage.getStatus());
List<NodeInstance> activeNodes = stage.getActiveNodes();
assertEquals(1, activeNodes.size());
assertEquals("Provide accident information", activeNodes.get(0).getName());
assertEquals("HumanTaskNode", activeNodes.get(0).getNodeType());
assertEquals(2, stage.getAdHocFragments().size());
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceAdminServiceIntegrationTest method assertSLAComplianceAfterWaiting.
private void assertSLAComplianceAfterWaiting(Long pid, int slaCompliance, int waitingTime) throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
assertFalse(latch.await(waitingTime, TimeUnit.SECONDS));
List<NodeInstance> activeNodes = processClient.findActiveNodeInstances(CONTAINER_ID, pid, 0, 10);
assertThat(activeNodes).hasSize(1);
assertEquals("SLA compliance should be " + slaCompliance + " after updating the timer and waiting " + waitingTime + " seconds", slaCompliance, activeNodes.get(0).getSlaCompliance().intValue());
}
Aggregations