use of org.kie.server.api.model.instance.TaskSummary in project droolsjbpm-integration by kiegroup.
the class TaskSearchServiceIntegrationTest method testFindTaskWithAndEqualsToFilter.
@Test
public void testFindTaskWithAndEqualsToFilter() throws Exception {
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK);
Assertions.assertThat(processInstanceId).isNotNull();
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
Assertions.assertThat(tasks).isNotEmpty();
TaskSummary task = tasks.get(0);
HashMap<TaskField, Comparable<?>> compareList = new HashMap<>();
compareList.put(TaskField.TASKID, task.getId());
compareList.put(TaskField.DEPLOYMENTID, CONTAINER_ID);
compareList.put(TaskField.PROCESSINSTANCEID, processInstanceId);
compareList.put(TaskField.NAME, FIRST_TASK_NAME);
compareList.put(TaskField.CREATEDBY, USER_YODA);
compareList.put(TaskField.ACTUALOWNER, USER_YODA);
compareList.put(TaskField.DESCRIPTION, task.getDescription());
compareList.put(TaskField.DUEDATE, task.getExpirationTime());
compareList.put(TaskField.PRIORITY, task.getPriority());
compareList.put(TaskField.STATUS, task.getStatus());
List<Long> resultsIds = new ArrayList<>();
List<TaskInstance> results = queryClient.findHumanTasksWithFilters(QUERY_NAME, createQueryFilterAndEqualsTo(compareList), 0, 100);
for (TaskInstance res : results) {
resultsIds.add(res.getId());
}
Assertions.assertThat(results).isNotNull();
Assertions.assertThat(results).isNotEmpty();
Assertions.assertThat(resultsIds).contains(task.getId());
TaskInstance instance = results.stream().filter(taskInstance -> taskInstance.getId().equals(task.getId())).findFirst().orElse(null);
Assertions.assertThat(instance).isNotNull();
Assertions.assertThat(instance.getContainerId()).isEqualTo(CONTAINER_ID);
Assertions.assertThat(instance.getProcessInstanceId()).isEqualTo(processInstanceId);
Assertions.assertThat(instance.getName()).isEqualTo(FIRST_TASK_NAME);
Assertions.assertThat(instance.getActualOwner()).isEqualTo(USER_YODA);
Assertions.assertThat(instance.getCreatedBy()).isEqualTo(USER_YODA);
Assertions.assertThat(instance.getDescription()).isEqualTo(task.getDescription());
Assertions.assertThat(instance.getExpirationDate()).isEqualTo(task.getExpirationTime());
Assertions.assertThat(instance.getPriority()).isEqualTo(task.getPriority());
Assertions.assertThat(instance.getStatus()).isEqualTo(task.getStatus());
}
use of org.kie.server.api.model.instance.TaskSummary in project droolsjbpm-integration by kiegroup.
the class TimerRollbackRegressionIntegrationTest method testTimerRollbackTimerCancel.
@Test(timeout = 60 * 1000)
public void testTimerRollbackTimerCancel() throws Exception {
String containerId = "timer-rollback-project-" + runtimeStrategy;
createContainer(containerId, releaseId, new KieServerConfigItem(KieServerConstants.PCFG_RUNTIME_STRATEGY, runtimeStrategy, String.class.getName()));
Long pid = this.processClient.startProcess(containerId, "error-handling.test-rollback");
// this should fail
try {
List<TaskSummary> summary = taskClient.findTasksAssignedAsPotentialOwner(USER_JOHN, 0, 10);
assertEquals(1, summary.size());
long taskId = summary.get(0).getId();
this.taskClient.startTask(containerId, taskId, summary.get(0).getActualOwner());
this.taskClient.completeTask(containerId, taskId, summary.get(0).getActualOwner(), Collections.emptyMap());
// shout not reach as complete task should throw an exception
Assert.fail();
} catch (Exception e) {
// do nothing as it should fail
}
Thread.sleep(6000L);
// the timer should still be active and triggered
ProcessInstance processInstance = this.queryClient.findProcessInstanceById(pid);
assertEquals((Integer) 2, processInstance.getState());
}
use of org.kie.server.api.model.instance.TaskSummary in project droolsjbpm-integration by kiegroup.
the class UserTaskEscalationIntegrationTest method testRepeatedEscalationsWhenNotCompleted.
@Test(timeout = 15000)
// Potentially unstable on slow DBs.
@Category(Unstable.class)
public void testRepeatedEscalationsWhenNotCompleted() throws Exception {
Long processInstanceId;
processInstanceId = processClient.startProcess(CONTAINER_ID_NOTIFICATION, "repeatedEmailNotificationProcess");
assertNotNull(processInstanceId);
assertTrue(processInstanceId > 0);
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
Assertions.assertThat(tasks).hasSize(1);
taskClient.startTask(CONTAINER_ID_NOTIFICATION, tasks.get(0).getId(), USER_YODA);
Thread.sleep(6000L);
// 1 NotCompleted repeated notification
assertTotalOfEmails(1);
assertEmails("NotCompleted repeated notification every 5secs", "NotCompleted repeated notification every 5secs", USER_YODA, 1);
taskClient.completeTask(CONTAINER_ID_NOTIFICATION, tasks.get(0).getId(), USER_YODA, new HashMap<>());
Thread.sleep(6000L);
// No new notifications should be received
assertTotalOfEmails(1);
assertEmails("NotCompleted repeated notification every 5secs", "NotCompleted repeated notification every 5secs", USER_YODA, 1);
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID_NOTIFICATION, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED, processInstance.getState().intValue());
}
use of org.kie.server.api.model.instance.TaskSummary in project droolsjbpm-integration by kiegroup.
the class BARuntimeDataServiceIntegrationTest method testFindTaskAssignedAsBusinessAdmin.
@Test
public void testFindTaskAssignedAsBusinessAdmin() throws Exception {
changeUser(USER_ADMINISTRATOR);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("stringData", "waiting for signal");
parameters.put("personData", createPersonInstance(USER_JOHN));
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK, parameters);
try {
List<TaskSummary> tasks = taskClient.findTasksAssignedAsBusinessAdministrator(USER_ADMINISTRATOR, 0, 10);
assertNotNull(tasks);
assertEquals(1, tasks.size());
TaskSummary taskInstance = tasks.get(0);
assertNotNull(taskInstance);
assertEquals("First task", taskInstance.getName());
KieServerAssert.assertNullOrEmpty(taskInstance.getDescription());
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(-1, taskInstance.getParentId().longValue());
assertEquals(processInstanceId, taskInstance.getProcessInstanceId());
List<String> status = new ArrayList<String>();
status.add(Status.InProgress.toString());
tasks = taskClient.findTasksAssignedAsBusinessAdministrator(USER_ADMINISTRATOR, status, 0, 10);
assertNotNull(tasks);
assertEquals(0, tasks.size());
} finally {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
changeUser(TestConfig.getUsername());
}
}
use of org.kie.server.api.model.instance.TaskSummary in project droolsjbpm-integration by kiegroup.
the class UserTaskClientIntegrationTest method listTaskInstancesAsPotentialOwner.
private List<TaskSummary> listTaskInstancesAsPotentialOwner() {
final Map<String, Object> parameters = new HashMap<>();
parameters.put("userId", "yoda");
parameters.put("page", "0");
parameters.put("pageSize", "10");
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("userTask");
executionServerCommand.setOperation("findTasksAssignedAsPotentialOwner");
executionServerCommand.setParameters(parameters);
final Object response = runOnExecutionServer(executionServerCommand);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response).isInstanceOf(List.class);
final List<TaskSummary> taskInstances = (List<TaskSummary>) response;
return taskInstances;
}
Aggregations