use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class TaskAuditBaseTest method testExitAfterClaim.
@Test
public void testExitAfterClaim() {
// One potential owner, should go straight to state Reserved
Task task = new TaskFluent().setName("This is my task name 2").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<TaskSummary> allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Ready"));
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(0, allGroupAuditTasks.size());
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Reserved"));
taskService.exit(taskId, "Administrator");
List<AuditTask> allHistoryAuditTasks = taskAuditService.getAllAuditTasks(new QueryFilter(0, 0));
assertEquals(1, allHistoryAuditTasks.size());
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(0, allGroupAuditTasks.size());
}
use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class TaskAuditBaseTest method testDueDateUpdate.
private void testDueDateUpdate(Date oldDate, Date newDate, boolean changeExpected) {
Task task = new TaskFluent().setDueDate(oldDate).setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
taskService.setExpirationDate(taskId, newDate);
task = taskService.getTaskById(taskId);
Assertions.assertThat(task.getTaskData().getExpirationTime()).isEqualTo(newDate);
List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
Assertions.assertThat(auditTasks).hasSize(1);
Assertions.assertThat(auditTasks.get(0).getDueDate()).isEqualTo(newDate);
List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
if (changeExpected) {
Assertions.assertThat(taskEvents).hasSize(2);
Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldDate), String.valueOf(newDate));
} else {
Assertions.assertThat(taskEvents).hasSize(1);
}
}
use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class RuntimeDataServiceImpl method getTasksAssignedAsPotentialOwnerByExpirationDateOptional.
@Override
public List<TaskSummary> getTasksAssignedAsPotentialOwnerByExpirationDateOptional(String userId, List<Status> status, Date from, QueryFilter filter) {
List<TaskSummary> taskSummaries = null;
if (from != null) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("expirationDate", from);
QueryFilter qf = new QueryFilter("(t.taskData.expirationTime = :expirationDate or t.taskData.expirationTime is null)", params, "order by t.id DESC", filter.getOffset(), filter.getCount());
taskSummaries = getTasksAssignedAsPotentialOwnerByStatus(userId, status, qf);
} else {
QueryFilter qf = new QueryFilter(filter.getOffset(), filter.getCount());
taskSummaries = getTasksAssignedAsPotentialOwnerByStatus(userId, status, qf);
}
return taskSummaries;
}
use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class RuntimeDataServiceImpl method getTasksOwnedByExpirationDateOptional.
@Override
public List<TaskSummary> getTasksOwnedByExpirationDateOptional(String userId, List<Status> strStatuses, Date from, QueryFilter filter) {
List<TaskSummary> taskSummaries = null;
if (from != null) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("expirationDate", from);
QueryFilter qf = new QueryFilter("(t.taskData.expirationTime = :expirationDate or t.taskData.expirationTime is null)", params, "order by t.id DESC", filter.getOffset(), filter.getCount());
taskSummaries = getTasksOwnedByStatus(userId, strStatuses, qf);
} else {
QueryFilter qf = new QueryFilter(filter.getOffset(), filter.getCount());
taskSummaries = getTasksOwnedByStatus(userId, strStatuses, qf);
}
return taskSummaries;
}
use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class CaseRuntimeDataServiceImplTest method testTransitionBetweenStagesWithConditionsInCase.
@Test
public void testTransitionBetweenStagesWithConditionsInCase() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("owner", new UserImpl(USER));
Map<String, Object> data = new HashMap<>();
data.put("customData", "none");
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), TWO_STAGES_CONDITIONS_CASE_P_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), TWO_STAGES_CONDITIONS_CASE_P_ID, caseFile);
assertNotNull(caseId);
try {
Collection<CaseStageInstance> stage = caseRuntimeDataService.getCaseInstanceStages(caseId, true, new QueryContext(0, 1));
assertNotNull(stage);
assertEquals(1, stage.size());
assertEquals("Stage One", stage.iterator().next().getName());
assertEquals(StageStatus.Active, stage.iterator().next().getStatus());
Collection<AdHocFragment> adhocTasks = caseRuntimeDataService.getAdHocFragmentsForCase(caseId);
assertNotNull(adhocTasks);
assertEquals(1, adhocTasks.size());
assertEquals("Task 1", adhocTasks.iterator().next().getName());
caseService.triggerAdHocFragment(caseId, "Task 1", null);
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), "john", "Task 1", Status.Reserved);
Map<String, Object> params = new HashMap<>();
params.put("myData", "nextStage");
userTaskService.completeAutoProgress(tasks.get(0).getId(), "john", params);
stage = caseRuntimeDataService.getCaseInstanceStages(caseId, true, new QueryContext(0, 1));
assertNotNull(stage);
assertEquals(1, stage.size());
assertEquals("Stage Two", stage.iterator().next().getName());
assertEquals(StageStatus.Active, stage.iterator().next().getStatus());
adhocTasks = caseRuntimeDataService.getAdHocFragmentsForCase(caseId);
assertNotNull(adhocTasks);
assertEquals(1, adhocTasks.size());
assertEquals("Task 2", adhocTasks.iterator().next().getName());
caseService.triggerAdHocFragment(caseId, "Task 2", null);
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), "john", "Task 2", Status.Reserved);
params = new HashMap<>();
params.put("myData", "none");
userTaskService.completeAutoProgress(tasks.get(0).getId(), "john", params);
CaseInstance instance = caseService.getCaseInstance(caseId);
Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CLOSED.getId());
caseId = null;
} catch (Exception e) {
logger.error("Unexpected error {}", e.getMessage(), e);
fail("Unexpected exception " + e.getMessage());
} finally {
if (caseId != null) {
caseService.cancelCase(caseId);
}
}
}
Aggregations