use of pro.taskana.TaskService in project taskana by Taskana.
the class QueryTasksAccTest method testQueryForAttachmentInSummary.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForAttachmentInSummary() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, TaskNotFoundException, WorkbasketNotFoundException, ConcurrencyException, InvalidWorkbasketException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
Attachment attachment = createAttachment(// prio 99, SL P2000D
"DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3));
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
task.addAttachment(attachment);
taskService.updateTask(task);
List<TaskSummary> results = taskService.createTaskQuery().idIn("TKI:000000000000000000000000000000000000").list();
assertThat(results.size(), equalTo(1));
assertThat(results.get(0).getAttachmentSummaries().size(), equalTo(3));
AttachmentSummary att = results.get(0).getAttachmentSummaries().get(0);
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class QueryTasksAccTest method testQueryForCustom5.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom5() throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("5", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
assertThat(results.size(), equalTo(3));
String[] ids = results.stream().map(t -> {
try {
return t.getCustomAttribute("5");
} catch (InvalidArgumentException e) {
e.printStackTrace();
return "";
}
}).collect(Collectors.toList()).toArray(new String[0]);
List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("5", ids).list();
assertThat(result2.size(), equalTo(3));
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class QueryTasksAccTest method testQueryForCustom2.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom2() throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("2", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
assertThat(results.size(), equalTo(1));
String[] ids = results.stream().map(t -> {
try {
return t.getCustomAttribute("2");
} catch (InvalidArgumentException e) {
e.printStackTrace();
return "";
}
}).collect(Collectors.toList()).toArray(new String[0]);
List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("2", ids).list();
assertThat(result2.size(), equalTo(1));
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class QueryTasksAccTest method testQueryAndCountMatch.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testQueryAndCountMatch() {
TaskService taskService = taskanaEngine.getTaskService();
TaskQuery taskQuery = taskService.createTaskQuery();
List<TaskSummary> tasks = taskQuery.nameIn("Task99", "Task01", "Widerruf").list();
long numberOfTasks = taskQuery.nameIn("Task99", "Task01", "Widerruf").count();
Assert.assertEquals(numberOfTasks, tasks.size());
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class QueryTasksAccTest method testQueryTaskByCustomAttributes.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testQueryTaskByCustomAttributes() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.setClassificationKey("T2100");
// about 1 Meg
Map<String, String> customAttributesForCreate = createSimpleCustomProperties(20000);
newTask.setCustomAttributes(customAttributesForCreate);
Task createdTask = taskService.createTask(newTask);
assertNotNull(createdTask);
// query the task by custom attributes
TaskanaEngineProxyForTest engineProxy = new TaskanaEngineProxyForTest((TaskanaEngineImpl) taskanaEngine);
try {
SqlSession session = engineProxy.getSqlSession();
Configuration config = session.getConfiguration();
if (!config.hasMapper(TaskTestMapper.class)) {
config.addMapper(TaskTestMapper.class);
}
TaskTestMapper mapper = session.getMapper(TaskTestMapper.class);
engineProxy.openConnection();
List<TaskImpl> queryResult = mapper.selectTasksByCustomAttributeLike("%Property Value of Property_1339%");
assertTrue(queryResult.size() == 1);
Task retrievedTask = queryResult.get(0);
assertTrue(createdTask.getId().equals(retrievedTask.getId()));
// verify that the map is correctly retrieved from the database
Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributes();
assertNotNull(customAttributesFromDb);
assertTrue(customAttributesForCreate.equals(customAttributesFromDb));
} finally {
engineProxy.returnConnection();
}
}
Aggregations