use of pro.taskana.impl.TaskanaEngineProxyForTest 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.impl.TaskanaEngineProxyForTest in project taskana by Taskana.
the class WorkbasketServiceImplIntAutocommitTest method updateModifiedTimestamps.
private void updateModifiedTimestamps(Workbasket basket2, Workbasket basket3, Workbasket basket4, Workbasket basket1) {
// created and modified timestamps are set by WorkbasketServiceImpl to 'now' when the workbasket is created
// in order to create timestamps distict from the current time, we must use the mapper directly to bypass
// WorkbasketServiceImpl
TaskanaEngineProxyForTest engineProxy = new TaskanaEngineProxyForTest(taskanaEngineImpl);
SqlSession session = engineProxy.getSqlSession();
WorkbasketMapper mapper = session.getMapper(WorkbasketMapper.class);
WorkbasketImpl wb1 = (WorkbasketImpl) basket1;
WorkbasketImpl wb2 = (WorkbasketImpl) basket2;
WorkbasketImpl wb3 = (WorkbasketImpl) basket3;
WorkbasketImpl wb4 = (WorkbasketImpl) basket4;
engineProxy.openConnection();
wb1.setModified(now.minus(Duration.ofDays(10L)));
mapper.update(wb1);
wb2.setModified(now.minus(Duration.ofDays(15L)));
mapper.update(wb2);
wb3.setModified(now.minus(Duration.ofDays(20L)));
mapper.update(wb3);
wb4.setModified(now.minus(Duration.ofDays(30L)));
mapper.update(wb4);
engineProxy.returnConnection();
}
use of pro.taskana.impl.TaskanaEngineProxyForTest in project taskana by Taskana.
the class CreateTaskAccTest method testCreateSimpleTaskWithCustomAttributes.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCreateSimpleTaskWithCustomAttributes() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Map<String, String> customAttributesForCreate = createSimpleCustomProperties(13);
newTask.setCustomAttributes(customAttributesForCreate);
Task createdTask = taskService.createTask(newTask);
assertNotNull(createdTask);
assertEquals("T-Vertragstermin VERA", createdTask.getName());
assertEquals("1234567", createdTask.getPrimaryObjRef().getValue());
assertNotNull(createdTask.getCreated());
assertNotNull(createdTask.getModified());
assertNotNull(createdTask.getBusinessProcessId());
assertEquals(null, createdTask.getClaimed());
assertEquals(null, createdTask.getCompleted());
assertEquals(createdTask.getCreated(), createdTask.getModified());
assertEquals(createdTask.getCreated(), createdTask.getPlanned());
assertEquals(TaskState.READY, createdTask.getState());
assertEquals(null, createdTask.getParentBusinessProcessId());
assertEquals(2, createdTask.getPriority());
assertEquals(false, createdTask.isRead());
assertEquals(false, createdTask.isTransferred());
// verify that the database content is as expected
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();
String customProperties = mapper.getCustomAttributesAsString(createdTask.getId());
assertTrue(customProperties.contains("\"Property_13\":\"Property Value of Property_13\""));
assertTrue(customProperties.contains("\"Property_12\":\"Property Value of Property_12\""));
assertTrue(customProperties.contains("\"Property_11\":\"Property Value of Property_11\""));
assertTrue(customProperties.contains("\"Property_10\":\"Property Value of Property_10\""));
assertTrue(customProperties.contains("\"Property_9\":\"Property Value of Property_9\""));
assertTrue(customProperties.contains("\"Property_8\":\"Property Value of Property_8\""));
assertTrue(customProperties.contains("\"Property_7\":\"Property Value of Property_7\""));
assertTrue(customProperties.contains("\"Property_6\":\"Property Value of Property_6\""));
assertTrue(customProperties.contains("\"Property_5\":\"Property Value of Property_5\""));
assertTrue(customProperties.contains("\"Property_4\":\"Property Value of Property_4\""));
assertTrue(customProperties.contains("\"Property_3\":\"Property Value of Property_3\""));
assertTrue(customProperties.contains("\"Property_2\":\"Property Value of Property_2\""));
assertTrue(customProperties.contains("\"Property_1\":\"Property Value of Property_1\""));
} finally {
engineProxy.returnConnection();
}
// verify that the map is correctly retrieved from the database
Task retrievedTask = taskService.getTask(createdTask.getId());
Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributes();
assertNotNull(customAttributesFromDb);
assertTrue(customAttributesFromDb.equals(customAttributesForCreate));
}
use of pro.taskana.impl.TaskanaEngineProxyForTest 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