use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class TaskAuditBaseTest method testLifeCycleWithBAMEndWithFailed.
@Test
public void testLifeCycleWithBAMEndWithFailed() {
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<AuditTask> allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
taskService.release(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("InProgress", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "InProgress");
taskService.fail(taskId, "Darth Vader", null);
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Failed", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Failed");
}
use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class TaskAuditBaseTest method testDescriptionUpdate.
private void testDescriptionUpdate(String oldDescription, String newDescription, boolean changeExpected) {
Task task = new TaskFluent().setDescription(oldDescription).setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<I18NText> descriptions = new ArrayList<I18NText>();
descriptions.add(new I18NTextImpl("", newDescription));
taskService.setDescriptions(taskId, descriptions);
task = taskService.getTaskById(taskId);
Assertions.assertThat(task.getDescription()).isEqualTo(newDescription);
List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
Assertions.assertThat(auditTasks).hasSize(1);
Assertions.assertThat(auditTasks.get(0).getDescription()).isEqualTo(newDescription);
List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
if (changeExpected) {
Assertions.assertThat(taskEvents).hasSize(2);
Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldDescription), String.valueOf(newDescription));
} else {
Assertions.assertThat(taskEvents).hasSize(1);
}
}
use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class TaskAuditBaseTest method testPriorityUpdate.
private void testPriorityUpdate(int oldPriority, int newPriority, boolean changeExpected) {
Task task = new TaskFluent().setPriority(oldPriority).setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
taskService.setPriority(taskId, newPriority);
task = taskService.getTaskById(taskId);
Assertions.assertThat(task.getPriority()).isEqualTo(newPriority);
List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
Assertions.assertThat(auditTasks).hasSize(1);
Assertions.assertThat(auditTasks.get(0).getPriority()).isEqualTo(newPriority);
List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
if (changeExpected) {
Assertions.assertThat(taskEvents).hasSize(2);
Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldPriority), String.valueOf(newPriority));
} else {
Assertions.assertThat(taskEvents).hasSize(1);
}
}
use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class TaskAuditBaseTest method assertAuditTaskInfoGroup.
protected void assertAuditTaskInfoGroup(String group, String status, Long taskId) {
List<AuditTask> allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser(group, new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals(status));
assertBAMTask(taskId, status);
}
use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class CaseSLAComplianceTest method testStartCaseWithSLAEscalation.
@Test
public void testStartCaseWithSLAEscalation() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("owner", new UserImpl("john"));
roleAssignments.put("admin", new UserImpl("mary"));
Map<String, Object> data = new HashMap<>();
data.put("s", "Case with SLA");
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, caseFile);
assertNotNull(caseId);
assertEquals(HR_CASE_ID, caseId);
try {
CaseInstance cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_PENDING, cInstance.getSlaCompliance().intValue());
List<TaskSummary> escalationTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("mary", new QueryFilter());
assertThat(escalationTasks).hasSize(0);
CountDownListenerFactory.getExisting("slaCompliance").waitTillCompleted();
cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_VIOLATED, cInstance.getSlaCompliance().intValue());
escalationTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("mary", new QueryFilter());
assertThat(escalationTasks).hasSize(1);
TaskSummary task = escalationTasks.get(0);
assertThat(task.getName()).isEqualTo("SLA violation for case " + caseId);
assertThat(task.getDescription()).isEqualTo("Service Level Agreement has been violated for case " + caseId);
caseService.cancelCase(caseId);
CaseInstance instance = caseService.getCaseInstance(caseId);
Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CANCELLED.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