use of pro.taskana.TaskService in project taskana by Taskana.
the class UpdateTaskAccTest method testUpdateTasksByPorForUser1.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testUpdateTasksByPorForUser1() throws InvalidArgumentException {
ObjectReference por = new ObjectReference();
por.setCompany("00");
por.setSystem("PASystem");
por.setSystemInstance("00");
por.setType("VNR");
por.setValue("22334455");
Map<String, String> customProperties = new HashMap<>();
customProperties.put("7", "This is modifiedValue 7");
customProperties.put("14", null);
customProperties.put("3", "This is modifiedValue 3");
customProperties.put("16", "This is modifiedValue 16");
TaskService taskService = taskanaEngine.getTaskService();
List<String> taskIds = taskService.updateTasks(por, customProperties);
assertEquals(0, taskIds.size());
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class UpdateTaskAccTest method testUpdateTasksByPor.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testUpdateTasksByPor() throws InvalidArgumentException, TaskNotFoundException, NotAuthorizedException {
ObjectReference por = new ObjectReference();
por.setCompany("00");
por.setSystem("PASystem");
por.setSystemInstance("00");
por.setType("VNR");
por.setValue("22334455");
Map<String, String> customProperties = new HashMap<>();
customProperties.put("7", "This is modifiedValue 7");
customProperties.put("14", null);
customProperties.put("3", "This is modifiedValue 3");
customProperties.put("16", "This is modifiedValue 16");
TaskService taskService = taskanaEngine.getTaskService();
List<String> taskIds = taskService.updateTasks(por, customProperties);
assertEquals(6, taskIds.size());
for (String taskId : taskIds) {
Task task = taskService.getTask(taskId);
assertEquals("This is modifiedValue 3", task.getCustomAttribute("3"));
assertEquals("This is modifiedValue 7", task.getCustomAttribute("7"));
assertEquals("This is modifiedValue 16", task.getCustomAttribute("16"));
assertNull(task.getCustomAttribute("14"));
}
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class UpdateTaskAccTest method testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
task.setPrimaryObjRef(null);
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", null));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", null, "1234567"));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", null, "VNR", "1234567"));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference("COMPANY_A", null, "INSTANCE_A", "VNR", "1234567"));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference(null, "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class UpdateTaskAccTest method testThrowsExceptionIfTaskHasAlreadyBeenUpdated.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testThrowsExceptionIfTaskHasAlreadyBeenUpdated() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
Task task2 = taskService.getTask("TKI:000000000000000000000000000000000000");
task.setCustomAttribute("1", "willi");
Task updatedTask = null;
updatedTask = taskService.updateTask(task);
updatedTask = taskService.getTask(updatedTask.getId());
task2.setCustomAttribute("2", "Walter");
try {
updatedTask = taskService.updateTask(task2);
} catch (ConcurrencyException ex) {
assertEquals("The task has already been updated by another user", ex.getMessage());
}
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class UpdateTaskAccTest method testCustomPropertiesOfTask.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCustomPropertiesOfTask() throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
task.setCustomAttribute("1", "T2100");
Task updatedTask = taskService.updateTask(task);
updatedTask = taskService.getTask(updatedTask.getId());
assertNotNull(updatedTask);
}
Aggregations