use of pro.taskana.TaskService in project taskana by Taskana.
the class TaskQueryAccTest method testTaskQueryUser_1_1Admin.
@WithAccessId(userName = "user_1_1", groupNames = { "admin" })
@Test
public void testTaskQueryUser_1_1Admin() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery().ownerLike("%a%", "%u%").list();
assertThat(results.size(), equalTo(25));
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class CreateTaskAccTest method testPrioDurationOfTaskFromAttachmentsAtCreate.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testPrioDurationOfTaskFromAttachmentsAtCreate() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
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 CreateTaskAccTest method testCreateExternalTaskWithAttachment.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCreateExternalTaskWithAttachment() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("L12010");
Map<String, String> customAttributesForCreate = createSimpleCustomProperties(27);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", customAttributesForCreate));
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Task createdTask = taskService.createTask(newTask);
assertNotNull(createdTask.getId());
assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
// verify that the database content is as expected
TaskanaEngineProxyForTest engineProxy = new TaskanaEngineProxyForTest((TaskanaEngineImpl) taskanaEngine);
try {
SqlSession session = engineProxy.getSqlSession();
AttachmentMapper mapper = session.getMapper(AttachmentMapper.class);
engineProxy.openConnection();
String customProperties = mapper.getCustomAttributesAsString(createdTask.getAttachments().get(0).getId());
assertTrue(customProperties.contains("\"Property_26\":\"Property Value of Property_26\""));
assertTrue(customProperties.contains("\"Property_25\":\"Property Value of Property_25\""));
assertTrue(customProperties.contains("\"Property_21\":\"Property Value of Property_21\""));
assertTrue(customProperties.contains("\"Property_19\":\"Property Value of Property_19\""));
assertTrue(customProperties.contains("\"Property_16\":\"Property Value of Property_16\""));
assertTrue(customProperties.contains("\"Property_12\":\"Property Value of Property_12\""));
assertTrue(customProperties.contains("\"Property_11\":\"Property Value of Property_11\""));
assertTrue(customProperties.contains("\"Property_7\":\"Property Value of Property_7\""));
assertTrue(customProperties.contains("\"Property_6\":\"Property Value of Property_6\""));
} finally {
engineProxy.returnConnection();
}
Task readTask = taskService.getTask(createdTask.getId());
assertNotNull(readTask);
assertThat(readTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
assertNotNull(readTask.getAttachments());
assertEquals(1, readTask.getAttachments().size());
assertNotNull(readTask.getAttachments().get(0).getCreated());
assertNotNull(readTask.getAttachments().get(0).getModified());
assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(0).getModified());
assertNotNull(readTask.getAttachments().get(0).getClassificationSummary());
assertNotNull(readTask.getAttachments().get(0).getObjectReference());
// verify that the map is correctly retrieved from the database
Map<String, String> customAttributesFromDb = readTask.getAttachments().get(0).getCustomAttributes();
assertNotNull(customAttributesFromDb);
assertTrue(customAttributesFromDb.equals(customAttributesForCreate));
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class CreateTaskAccTest method testCreateExternalTaskWithMultipleAttachments.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCreateExternalTaskWithMultipleAttachments() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("L12010");
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", 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());
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class CreateTaskAccTest method testSetDomainFromWorkbasket.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testSetDomainFromWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
TaskService taskService = taskanaEngine.getTaskService();
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
Task newTask = taskService.newTask("WBI:100000000000000000000000000000000006");
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Task createdTask = taskService.createTask(newTask);
assertNotNull(createdTask);
assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
assertNotNull(createdTask.getDomain());
assertEquals(workbasket.getDomain(), createdTask.getDomain());
}
Aggregations