use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class SLAComplianceIntegrationTest method testSLAonUserTaskViolated.
@Test
@Category({ UnstableOnJenkinsPrBuilder.class })
public void testSLAonUserTaskViolated() throws Exception {
Long pid = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK_WITH_SLA_ON_TASK, new HashMap<>());
assertProcessInstance(pid, STATE_ACTIVE, SLA_NA);
// Yoda should have one task available with SLA
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
TaskSummary task = tasks.get(0);
assertThat(tasks).hasSize(1);
assertThat(task.getName()).isEqualTo("Hello");
List<NodeInstance> activeNodes = processClient.findActiveNodeInstances(CONTAINER_ID, pid, 0, 10);
assertThat(activeNodes).hasSize(1);
NodeInstance taskNode = activeNodes.get(0);
assertNodeInstance(taskNode, "Hello", SLA_PENDING);
// Let's wait for SLA violation
KieServerSynchronization.waitForNodeInstanceSLAViolated(queryClient, pid, taskNode.getId(), 8_000L);
assertProcessInstance(pid, STATE_ACTIVE, SLA_NA);
activeNodes = processClient.findActiveNodeInstances(CONTAINER_ID, pid, 0, 10);
assertThat(activeNodes).hasSize(1);
taskNode = activeNodes.get(0);
assertNodeInstance(taskNode, "Hello", SLA_VIOLATED);
taskClient.completeAutoProgress(CONTAINER_ID, task.getId(), USER_YODA, null);
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertThat(tasks).isEmpty();
activeNodes = processClient.findActiveNodeInstances(CONTAINER_ID, pid, 0, 10);
assertThat(activeNodes).isEmpty();
taskNode = getNodeInstanceById(queryClient.findCompletedNodeInstances(pid, 0, 10), taskNode.getId());
assertNodeInstance(taskNode, "Hello", SLA_VIOLATED);
assertProcessInstance(pid, STATE_COMPLETED, SLA_NA);
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class SLAComplianceIntegrationTest method testSLAonUserTaskMet.
@Test
public void testSLAonUserTaskMet() throws Exception {
Long pid = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK_WITH_SLA_ON_TASK, new HashMap<>());
assertProcessInstance(pid, STATE_ACTIVE, SLA_NA);
// Yoda should have one task available with SLA
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
TaskSummary task = tasks.get(0);
assertThat(tasks).hasSize(1);
assertThat(task.getName()).isEqualTo("Hello");
List<NodeInstance> activeNodes = processClient.findActiveNodeInstances(CONTAINER_ID, pid, 0, 10);
assertThat(activeNodes).hasSize(1);
NodeInstance taskNode = activeNodes.get(0);
assertNodeInstance(taskNode, "Hello", SLA_PENDING);
taskClient.completeAutoProgress(CONTAINER_ID, task.getId(), USER_YODA, null);
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertThat(tasks).isEmpty();
activeNodes = processClient.findActiveNodeInstances(CONTAINER_ID, pid, 0, 10);
assertThat(activeNodes).isEmpty();
taskNode = getNodeInstanceById(queryClient.findCompletedNodeInstances(pid, 0, 10), taskNode.getId());
assertNodeInstance(taskNode, "Hello", SLA_MET);
assertProcessInstance(pid, STATE_COMPLETED, SLA_NA);
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class StartProcessServiceIntegrationTest method testStartProcessFromNodeIdWithCorrelationKeyProcess.
@Test()
public void testStartProcessFromNodeIdWithCorrelationKeyProcess() {
Map<String, Object> parameters = new HashMap<>();
Long processInstanceId = processClient.startProcess(CONTAINER_ID_RESTART, PROCESS_ID_RESTART, parameters);
try {
assertNotNull(processInstanceId);
assertTrue(processInstanceId > 0);
// Process instance is running and is active.
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID_RESTART, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE, processInstance.getState().intValue());
processClient.abortProcessInstance(CONTAINER_ID_RESTART, processInstanceId);
List<NodeInstance> list = this.processClient.findNodeInstancesByType(CONTAINER_ID_RESTART, 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;
processInstanceId = processClient.startProcessFromNodeIds(CONTAINER_ID_RESTART, PROCESS_ID_RESTART, firstKey, parameters, nodeIds);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE, processInstance.getState().intValue());
ProcessInstance pi = processClient.getProcessInstance(CONTAINER_ID_RESTART, processInstanceId);
assertThat(pi.getCorrelationKey(), is("mysimlekey"));
processClient.abortProcessInstance(CONTAINER_ID_RESTART, processInstanceId);
} catch (Exception e) {
if (processInstanceId != null) {
processClient.abortProcessInstance(CONTAINER_ID_RESTART, processInstanceId);
}
fail(e.getMessage());
}
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class StartProcessServiceIntegrationTest method testStartProcessFromNodeId.
@Test()
public void testStartProcessFromNodeId() {
Map<String, Object> parameters = new HashMap<>();
Long processInstanceId = processClient.startProcess(CONTAINER_ID_RESTART, PROCESS_ID_RESTART, parameters);
try {
assertNotNull(processInstanceId);
assertTrue(processInstanceId > 0);
// Process instance is running and is active.
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID_RESTART, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE, processInstance.getState().intValue());
processClient.abortProcessInstance(CONTAINER_ID_RESTART, processInstanceId);
List<NodeInstance> list = this.processClient.findNodeInstancesByType(CONTAINER_ID_RESTART, processInstanceId, "ABORTED", 0, 10);
String[] nodeIds = list.stream().map(NodeInstance::getNodeId).toArray(String[]::new);
processInstanceId = null;
processInstanceId = processClient.startProcessFromNodeIds(CONTAINER_ID_RESTART, PROCESS_ID_RESTART, parameters, nodeIds);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE, processInstance.getState().intValue());
list = this.processClient.findNodeInstancesByType(CONTAINER_ID_RESTART, processInstanceId, "START", 0, 10);
assertNotNull(list);
assertThat(list.size(), is(1));
assertThat(list.get(0).getName(), is("Human Task"));
processClient.abortProcessInstance(CONTAINER_ID_RESTART, processInstanceId);
} catch (Exception e) {
if (processInstanceId != null) {
processClient.abortProcessInstance(CONTAINER_ID_RESTART, processInstanceId);
}
fail(e.getMessage());
}
}
use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceAdminServiceIntegrationTest method assertSlaComplianceAndDueDate.
private void assertSlaComplianceAndDueDate(Long pid, Date dueDate, String entryType, int slaCompliance) {
List<NodeInstance> nodes = processClient.findNodeInstancesByType(CONTAINER_ID, pid, entryType, 0, 10);
NodeInstance userTask = nodes.stream().filter(n -> USER_TASK_NAME.equals(n.getName())).findFirst().orElseThrow(() -> new RuntimeException("Node '" + USER_TASK_NAME + "' not found as entryType " + entryType));
assertEquals(slaCompliance, userTask.getSlaCompliance().intValue());
assertThat(userTask.getSlaDueDate()).isCloseTo(dueDate, 2000);
}
Aggregations