use of org.kie.server.api.model.instance.TaskSummary in project droolsjbpm-integration by kiegroup.
the class SLAComplianceIntegrationTest method testSLAonProcessViolated.
@Test
@Category({ UnstableOnJenkinsPrBuilder.class })
public void testSLAonProcessViolated() throws Exception {
Long pid = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK_WITH_SLA, new HashMap<>());
assertProcessInstance(pid, STATE_ACTIVE, SLA_PENDING);
// Yoda should have one task available without SLA
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertThat(tasks).hasSize(1);
TaskSummary task = tasks.get(0);
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_NA);
// Let's wait for SLA violation
KieServerSynchronization.waitForProcessInstanceSLAViolated(queryClient, pid, 8_000L);
assertProcessInstance(pid, STATE_ACTIVE, SLA_VIOLATED);
taskClient.completeAutoProgress(CONTAINER_ID, task.getId(), USER_YODA, null);
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 0);
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_NA);
// Process should be completed, but SLA should still be violated
assertProcessInstance(pid, STATE_COMPLETED, SLA_VIOLATED);
}
use of org.kie.server.api.model.instance.TaskSummary in project droolsjbpm-integration by kiegroup.
the class SLAComplianceIntegrationTest method testSLAonProcessMet.
@Test
public void testSLAonProcessMet() throws Exception {
Long pid = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK_WITH_SLA, new HashMap<>());
assertProcessInstance(pid, STATE_ACTIVE, SLA_PENDING);
// Yoda should have one task available without SLA
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertThat(tasks).hasSize(1);
TaskSummary task = tasks.get(0);
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_NA);
// Complete task before SLA violation
taskClient.completeAutoProgress(CONTAINER_ID, task.getId(), USER_YODA, null);
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 0);
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_NA);
// Process should be completed and SLA should be met
assertProcessInstance(pid, STATE_COMPLETED, SLA_MET);
}
use of org.kie.server.api.model.instance.TaskSummary in project droolsjbpm-integration by kiegroup.
the class ProcessServiceIntegrationTest method testWorkItemOperationComplete.
@Test
public void testWorkItemOperationComplete() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION, parameters);
try {
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
// Completing human task so we can move in process flow to work item.
// User task shouldn't be handled as work item because in such case it doesn't behave consistently:
// i.e. leaving open tasks after finishing process instance.
List<String> status = Arrays.asList(Status.Ready.toString());
List<TaskSummary> taskList = taskClient.findTasksByStatusByProcessInstanceId(processInstanceId, status, 0, 10);
assertEquals(1, taskList.size());
TaskSummary taskSummary = taskList.get(0);
taskClient.startTask(CONTAINER_ID, taskSummary.getId(), USER_YODA);
taskClient.completeTask(CONTAINER_ID, taskSummary.getId(), USER_YODA, null);
TaskInstance userTask = taskClient.findTaskById(taskSummary.getId());
assertNotNull(userTask);
assertEquals("Evaluate items?", userTask.getName());
assertEquals(Status.Completed.toString(), userTask.getStatus());
List<WorkItemInstance> workItems = processClient.getWorkItemByProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(workItems);
assertEquals(1, workItems.size());
WorkItemInstance workItemInstance = workItems.get(0);
assertNotNull(workItemInstance);
processClient.completeWorkItem(CONTAINER_ID, processInstanceId, workItemInstance.getId(), parameters);
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED, processInstance.getState().intValue());
} catch (Exception e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
throw e;
} finally {
changeUser(TestConfig.getUsername());
}
}
use of org.kie.server.api.model.instance.TaskSummary 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.TaskSummary in project droolsjbpm-integration by kiegroup.
the class ProcessUserTaskServicesSecurityIntegrationTest method testNonAllowedUserForStartingProcessCanCompleteTask.
@Test
public void testNonAllowedUserForStartingProcessCanCompleteTask() throws Exception {
try {
Long processInstanceId = startProcessAsAdministrator(PROCESS_ID_USERTASK_SECURED);
changeUser(USER_YODA);
List<TaskSummary> taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertThat(taskList).isNotNull().hasSize(1);
Long taskId = taskList.get(0).getId();
taskClient.startTask(CONTAINER_ID_SECURED, taskId, USER_YODA);
taskClient.completeAutoProgress(CONTAINER_ID_SECURED, taskId, USER_YODA, new HashMap<String, Object>());
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID_SECURED, processInstanceId);
assertNotNull(processInstance);
assertEquals(STATE_COMPLETED, processInstance.getState().intValue());
} finally {
changeUser(TestConfig.getUsername());
}
}
Aggregations