use of pro.taskana.TaskService in project taskana by Taskana.
the class UpdateTaskAttachmentsAccTest method testPrioDurationOfTaskFromAttachmentsAtUpdate.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testPrioDurationOfTaskFromAttachmentsAtUpdate() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
setUpMethod();
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
// prio 8, SL P7D
newTask.setClassificationKey("L12010");
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.addAttachment(createAttachment(// prio 99, SL P2000D
"DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
newTask.addAttachment(createAttachment(// prio 1, SL P1D
"L1060", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
Task createdTask = taskService.createTask(newTask);
assertNotNull(createdTask.getId());
assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
Task readTask = taskService.getTask(createdTask.getId());
assertNotNull(readTask);
assertThat(readTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
assertNotNull(readTask.getAttachments());
assertEquals(2, readTask.getAttachments().size());
assertNotNull(readTask.getAttachments().get(1).getCreated());
assertNotNull(readTask.getAttachments().get(1).getModified());
assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(1).getModified());
// assertNotNull(readTask.getAttachments().get(0).getClassification());
assertNotNull(readTask.getAttachments().get(0).getObjectReference());
assertTrue(readTask.getPriority() == 99);
DaysToWorkingDaysConverter converter = DaysToWorkingDaysConverter.initialize(Collections.singletonList(new TimeIntervalColumnHeader(0)), Instant.now());
long calendarDays = converter.convertWorkingDaysToDays(readTask.getPlanned(), 1);
assertTrue(readTask.getDue().equals(readTask.getPlanned().plus(Duration.ofDays(calendarDays))));
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class UpdateClassificationAccTest method testUpdateClassificationPrioServiceLevel.
@WithAccessId(userName = "dummy", groupNames = { "admin" })
@Test
public void testUpdateClassificationPrioServiceLevel() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, InterruptedException, TaskNotFoundException, InvalidArgumentException {
String newEntryPoint = "updated EntryPoint";
Instant before = Instant.now();
ClassificationService classificationService = taskanaEngine.getClassificationService();
Classification classification = classificationService.getClassification("CLI:100000000000000000000000000000000003");
Instant createdBefore = classification.getCreated();
Instant modifiedBefore = classification.getModified();
classification.setPriority(1000);
classification.setServiceLevel("P15D");
classificationService.updateClassification(classification);
Thread.sleep(100);
JobRunner runner = new JobRunner(taskanaEngine);
runner.runJobs();
// Get and check the new value
Classification updatedClassification = classificationService.getClassification("CLI:100000000000000000000000000000000003");
assertNotNull(updatedClassification);
assertTrue(!modifiedBefore.isAfter(updatedClassification.getModified()));
List<String> affectedTasks = new ArrayList<>(Arrays.asList("TKI:000000000000000000000000000000000000", "TKI:000000000000000000000000000000000003", "TKI:000000000000000000000000000000000004", "TKI:000000000000000000000000000000000005", "TKI:000000000000000000000000000000000006", "TKI:000000000000000000000000000000000007", "TKI:000000000000000000000000000000000008", "TKI:000000000000000000000000000000000009", "TKI:000000000000000000000000000000000010", "TKI:000000000000000000000000000000000011", "TKI:000000000000000000000000000000000012", "TKI:000000000000000000000000000000000013", "TKI:000000000000000000000000000000000014", "TKI:000000000000000000000000000000000015", "TKI:000000000000000000000000000000000016", "TKI:000000000000000000000000000000000017", "TKI:000000000000000000000000000000000018", "TKI:000000000000000000000000000000000019", "TKI:000000000000000000000000000000000020", "TKI:000000000000000000000000000000000021", "TKI:000000000000000000000000000000000022", "TKI:000000000000000000000000000000000023", "TKI:000000000000000000000000000000000024", "TKI:000000000000000000000000000000000025", "TKI:000000000000000000000000000000000026", "TKI:000000000000000000000000000000000027", "TKI:000000000000000000000000000000000028", "TKI:000000000000000000000000000000000029", "TKI:000000000000000000000000000000000030", "TKI:000000000000000000000000000000000031", "TKI:000000000000000000000000000000000032", "TKI:000000000000000000000000000000000033", "TKI:000000000000000000000000000000000034", "TKI:000000000000000000000000000000000035", "TKI:000000000000000000000000000000000053", "TKI:000000000000000000000000000000000054", "TKI:000000000000000000000000000000000055", "TKI:000000000000000000000000000000000100", "TKI:000000000000000000000000000000000101", "TKI:000000000000000000000000000000000102", "TKI:000000000000000000000000000000000103"));
TaskService taskService = taskanaEngine.getTaskService();
DaysToWorkingDaysConverter converter = DaysToWorkingDaysConverter.initialize(Collections.singletonList(new TimeIntervalColumnHeader(0)), Instant.now());
for (String taskId : affectedTasks) {
Task task = taskService.getTask(taskId);
assertTrue(task.getModified().isAfter(before));
assertTrue(task.getPriority() == 1000);
long calendarDays = converter.convertWorkingDaysToDays(task.getPlanned(), 15);
if (!taskId.equals("TKI:000000000000000000000000000000000008") && !taskId.equals("TKI:000000000000000000000000000000000053")) {
assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(calendarDays))));
}
}
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class DeleteTaskAccTest method testBulkDeleteTasksWithException.
@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test(expected = TaskNotFoundException.class)
public void testBulkDeleteTasksWithException() throws TaskNotFoundException, InvalidArgumentException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
ArrayList<String> taskIdList = new ArrayList<>();
taskIdList.add("TKI:000000000000000000000000000000000039");
taskIdList.add("TKI:000000000000000000000000000000000040");
taskIdList.add("TKI:000000000000000000000000000000000028");
BulkOperationResults<String, TaskanaException> results = taskService.deleteTasks(taskIdList);
String expectedFailedId = "TKI:000000000000000000000000000000000028";
assertTrue(results.containsErrors());
List<String> failedTaskIds = results.getFailedIds();
assertTrue(failedTaskIds.size() == 1);
assertTrue(expectedFailedId.equals(failedTaskIds.get(0)));
assertTrue(results.getErrorMap().get(expectedFailedId).getClass() == InvalidStateException.class);
Task notDeletedTask = taskService.getTask("TKI:000000000000000000000000000000000028");
assertTrue(notDeletedTask != null);
taskService.getTask("TKI:000000000000000000000000000000000040");
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class TaskQueryAccTest method testTaskQueryUser_1_1BusinessAdm.
@WithAccessId(userName = "user_1_1", groupNames = { "businessadmin" })
@Test
public void testTaskQueryUser_1_1BusinessAdm() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery().ownerLike("%a%", "%u%").list();
assertThat(results.size(), equalTo(3));
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class TaskQueryAccTest method testTaskQueryUser_1_1.
@WithAccessId(// , groupNames = {"businessadmin"})
userName = "user_1_1")
@Test
public void testTaskQueryUser_1_1() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery().ownerLike("%a%", "%u%").list();
assertThat(results.size(), equalTo(3));
}
Aggregations