use of org.kie.server.api.model.instance.TaskInstance in project droolsjbpm-integration by kiegroup.
the class UserTaskEscalationIntegrationTest method testEscalation.
@Test
@Category(Unstable.class)
public void testEscalation() throws InterruptedException, MessagingException, Exception {
// Unstable on slow DBs where completing of the task overlaps with escalation causing race conditions in Hibernate.
// Could be stabilized using specific transaction isolation.
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK_ESCALATION, params);
assertNotNull(processInstanceId);
assertTrue(processInstanceId > 0);
try {
List<TaskSummary> taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertNotNull(taskList);
assertEquals(1, taskList.size());
TaskSummary taskSummary = taskList.get(0);
assertEquals("User Task", taskSummary.getName());
Long taskId = taskSummary.getId();
TaskInstance taskInstance = taskClient.findTaskById(taskId);
assertNotNull(taskInstance);
assertEquals(USER_YODA, taskInstance.getActualOwner());
changeUser(USER_JOHN);
waitForAssign(taskId, USER_JOHN);
taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_JOHN, 0, 10);
assertNotNull(taskList);
assertEquals(1, taskList.size());
taskId = taskList.get(0).getId();
taskInstance = taskClient.findTaskById(taskId);
assertNotNull(taskInstance);
taskClient.startTask(CONTAINER_ID, taskId, USER_JOHN);
taskInstance = taskClient.findTaskById(taskId);
assertNotNull(taskInstance);
assertEquals(USER_JOHN, taskInstance.getActualOwner());
waitForEmailsReceive(wiser);
taskClient.completeTask(CONTAINER_ID, taskId, USER_JOHN, new HashMap<String, Object>());
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED, processInstance.getState().intValue());
assertTotalOfEmails(1);
assertEmails("Escalation", ESCALATION_TEXT, USER_JOHN, 1);
} catch (Exception e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
throw e;
} finally {
changeUser(TestConfig.getUsername());
}
}
use of org.kie.server.api.model.instance.TaskInstance in project droolsjbpm-integration by kiegroup.
the class UserTaskServiceIntegrationTest method testAllowedUserTaskUpdateOutputVariable.
@Test
public void testAllowedUserTaskUpdateOutputVariable() {
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK);
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
try {
List<TaskSummary> taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertNotNull(taskList);
assertEquals(1, taskList.size());
TaskSummary taskSummary = taskList.get(0);
taskClient.startTask(CONTAINER_ID, taskSummary.getId(), USER_YODA);
Map<String, Object> outputData = new HashMap<>();
outputData.put("string_", "my custom data");
outputData.put("person_", createPersonInstance(USER_MARY));
taskClient.saveTaskContent(CONTAINER_ID, taskSummary.getId(), outputData);
// retrieve started task
TaskInstance taskInstance = taskClient.getTaskInstance(CONTAINER_ID, taskSummary.getId(), true, true, false);
Object personVar = taskInstance.getOutputData().get("person_");
assertNotNull(personVar);
assertEquals(USER_MARY, KieServerReflections.valueOf(personVar, "name"));
String stringVar = (String) taskInstance.getOutputData().get("string_");
assertNotNull(personVar);
assertEquals("my custom data", stringVar);
} finally {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
use of org.kie.server.api.model.instance.TaskInstance in project droolsjbpm-integration by kiegroup.
the class UserTaskServiceIntegrationTest method checkTaskStatusAndOwners.
private void checkTaskStatusAndOwners(String containerId, Long taskId, Status status, String actualOwner, String potentialOwner) {
TaskInstance task = taskClient.getTaskInstance(containerId, taskId, false, false, true);
checkTaskStatusAndActualOwner(containerId, taskId, status, actualOwner);
assertEquals(1, task.getPotentialOwners().size());
assertEquals(potentialOwner, task.getPotentialOwners().get(0));
}
use of org.kie.server.api.model.instance.TaskInstance in project droolsjbpm-integration by kiegroup.
the class UserTaskServiceIntegrationTest method testUserTaskByIdWithDetails.
@Test
public void testUserTaskByIdWithDetails() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("stringData", "john is working on it");
parameters.put("personData", createPersonInstance(USER_JOHN));
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK, parameters);
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
try {
List<TaskSummary> taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertNotNull(taskList);
assertEquals(1, taskList.size());
TaskSummary taskSummary = taskList.get(0);
assertEquals("First task", taskSummary.getName());
TaskInstance taskInstance = taskClient.getTaskInstance(CONTAINER_ID, taskSummary.getId(), true, true, true);
assertNotNull(taskInstance);
assertEquals("First task", taskInstance.getName());
KieServerAssert.assertNullOrEmpty(taskInstance.getDescription());
KieServerAssert.assertNullOrEmpty(taskInstance.getSubject());
assertEquals("Reserved", taskInstance.getStatus());
assertEquals(0, taskInstance.getPriority().intValue());
assertEquals(USER_YODA, taskInstance.getActualOwner());
assertEquals(USER_YODA, taskInstance.getCreatedBy());
assertEquals(PROCESS_ID_USERTASK, taskInstance.getProcessId());
assertEquals(CONTAINER_ID, taskInstance.getContainerId());
assertEquals(taskSummary.getId(), taskInstance.getId());
assertEquals(-1, taskInstance.getParentId().longValue());
assertEquals(true, taskInstance.getSkipable());
assertEquals(processInstanceId, taskInstance.getProcessInstanceId());
assertNotNull(taskInstance.getWorkItemId());
assertTrue(taskInstance.getWorkItemId().longValue() > 0);
assertNotNull(taskInstance.getExcludedOwners());
assertEquals(0, taskInstance.getExcludedOwners().size());
assertNotNull(taskInstance.getPotentialOwners());
assertEquals(1, taskInstance.getPotentialOwners().size());
assertTrue(taskInstance.getPotentialOwners().contains(USER_YODA));
assertNotNull(taskInstance.getBusinessAdmins());
assertEquals(2, taskInstance.getBusinessAdmins().size());
assertTrue(taskInstance.getBusinessAdmins().contains(USER_ADMINISTRATOR));
assertTrue(taskInstance.getBusinessAdmins().contains("Administrators"));
assertNotNull(taskInstance.getInputData());
assertEquals(6, taskInstance.getInputData().size());
Map<String, Object> inputs = taskInstance.getInputData();
assertTrue(inputs.containsKey("ActorId"));
assertTrue(inputs.containsKey("_string"));
assertTrue(inputs.containsKey("Skippable"));
assertTrue(inputs.containsKey("_person"));
assertTrue(inputs.containsKey("NodeName"));
assertEquals(USER_YODA, inputs.get("ActorId"));
assertEquals("john is working on it", inputs.get("_string"));
assertEquals("true", inputs.get("Skippable"));
assertEquals("First task", inputs.get("NodeName"));
assertEquals(USER_JOHN, KieServerReflections.valueOf(inputs.get("_person"), "name"));
assertNotNull(taskInstance.getOutputData());
assertEquals(0, taskInstance.getOutputData().size());
} finally {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
use of org.kie.server.api.model.instance.TaskInstance in project droolsjbpm-integration by kiegroup.
the class QueryDataServiceIntegrationTest method testDefaultQueryJbpmHumanTasksWithAdmin.
@Test
public void testDefaultQueryJbpmHumanTasksWithAdmin() {
QueryDefinition registeredQuery = queryClient.getQuery("jbpmHumanTasksWithAdmin");
List<TaskInstance> tasks = queryClient.query(registeredQuery.getName(), QueryServicesClient.QUERY_MAP_TASK, 0, 10, TaskInstance.class);
assertNotNull(tasks);
}
Aggregations