use of pro.taskana.TaskService in project taskana by Taskana.
the class CreateTaskAccTest method testGetExceptionIfAppendIsNotPermitted.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test(expected = NotAuthorizedException.class)
public void testGetExceptionIfAppendIsNotPermitted() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("GPK_KSC", "DOMAIN_A");
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
taskService.createTask(newTask);
}
use of pro.taskana.TaskService 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.TaskService in project taskana by Taskana.
the class CreateTaskAccTest method testThrowsExceptionIfAttachmentIsInvalid.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testThrowsExceptionIfAttachmentIsInvalid() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", null, "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue Attachment-ObjRef is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", null), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Value is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", null, "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Type is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", null, "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-SystemInstance is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", null, "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-System is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference(null, "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Company is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class CreateTaskAccTest method testUseCustomNameIfSetForNewTask.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testUseCustomNameIfSetForNewTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
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"));
newTask.setName("Test Name");
Task createdTask = taskService.createTask(newTask);
assertNotNull(createdTask);
assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
assertEquals("Test Name", createdTask.getName());
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class CreateTaskAccTest method testCreateSimpleManualTask.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCreateSimpleManualTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
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"));
Task createdTask = taskService.createTask(newTask);
assertNotNull(createdTask);
assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
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());
}
Aggregations