use of pro.taskana.impl.TaskImpl in project taskana by Taskana.
the class UpdateTaskAttachmentsAccTest method testUpdateAttachment.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testUpdateAttachment() throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException, SQLException {
setUpMethod();
((TaskImpl) task).setAttachments(new ArrayList<>());
task = taskService.updateTask(task);
assertTrue(task.getPriority() == 1);
assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(1))));
Attachment attachment = this.attachment;
task.addAttachment(attachment);
task = taskService.updateTask(task);
assertTrue(task.getPriority() == 99);
assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(1))));
int attachmentCount = task.getAttachments().size();
String newChannel = attachment.getChannel() + "-X";
task.getAttachments().get(0).setChannel(newChannel);
Classification newClassification = taskanaEngine.getClassificationService().getClassification(// Prio 999, SL PT5H
"CLI:000000000000000000000000000000000001");
task.getAttachments().get(0).setClassificationSummary(newClassification.asSummary());
task = taskService.updateTask(task);
task = taskService.getTask(task.getId());
assertThat(task.getAttachments().size(), equalTo(attachmentCount));
assertThat(task.getAttachments().get(0).getChannel(), equalTo(newChannel));
assertTrue(task.getPriority() == 999);
assertTrue(task.getDue().equals(task.getPlanned()));
}
use of pro.taskana.impl.TaskImpl in project taskana by Taskana.
the class UpdateClassificationAccTest method testUpdateTaskOnClassificationKeyCategoryChange.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdateTaskOnClassificationKeyCategoryChange() throws Exception {
setupTest();
TaskImpl beforeTask = (TaskImpl) taskanaEngine.getTaskService().getTask("TKI:000000000000000000000000000000000000");
Classification classification = taskanaEngine.getClassificationService().getClassification(beforeTask.getClassificationSummary().getKey(), beforeTask.getDomain());
classification.setCategory("PROCESS");
Instant createdBefore = classification.getCreated();
Instant modifiedBefore = classification.getModified();
classification = taskanaEngine.getClassificationService().updateClassification(classification);
TaskImpl updatedTask = (TaskImpl) taskanaEngine.getTaskService().getTask("TKI:000000000000000000000000000000000000");
assertThat(updatedTask.getClassificationCategory(), not(equalTo(beforeTask.getClassificationCategory())));
assertThat(updatedTask.getClassificationSummary().getCategory(), not(equalTo(beforeTask.getClassificationSummary().getCategory())));
assertThat(updatedTask.getClassificationCategory(), equalTo("PROCESS"));
assertThat(updatedTask.getClassificationSummary().getCategory(), equalTo("PROCESS"));
assertThat(classification.getCreated(), equalTo(createdBefore));
assertTrue(modifiedBefore.isBefore(classification.getModified()));
}
use of pro.taskana.impl.TaskImpl in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method shouldNotTransferByFailingSecurity.
@WithAccessId(userName = "User", groupNames = { "businessadmin" })
@Test
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException, TaskNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
final String user = CurrentUserContext.getUserid();
// Set up Security for this Test
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, true);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
classificationService = taskanaEngine.getClassificationService();
workbasketService = taskanaEngine.getWorkbasketService();
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification);
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("k5", "DOMAIN_A");
wb.setName("BASE WB");
wb.setDescription("Normal base WB");
wb.setOwner(user);
wb.setType(WorkbasketType.TOPIC);
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("key77", "DOMAIN_A");
wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
wbNoAppend.setOwner(user);
wbNoAppend.setType(WorkbasketType.PERSONAL);
wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("k99", "DOMAIN_B");
wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
wbNoTransfer.setOwner(user);
wbNoTransfer.setType(WorkbasketType.CLEARANCE);
wbNoTransfer = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoTransfer);
createWorkbasketWithSecurity(wbNoTransfer, wbNoTransfer.getOwner(), true, true, true, false);
TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getId());
task.setName("Task Name");
task.setDescription("Task used for transfer Test");
task.setOwner(user);
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = (TaskImpl) taskServiceImpl.createTask(task);
// Check failing with missing APPEND
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wbNoAppend.getId());
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("APPEND")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
assertThat(task.getWorkbasketKey(), equalTo(wb.getKey()));
}
// Check failing with missing TRANSFER
task.setId("");
task.getWorkbasketSummaryImpl().setId(wbNoTransfer.getId());
task.setWorkbasketKey(null);
task = (TaskImpl) taskServiceImpl.createTask(task);
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wb.getId());
fail("Transfer Task should be FAILD, because there are no TRANSFER-Rights on current WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("TRANSFER")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on current WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
}
}
use of pro.taskana.impl.TaskImpl in project taskana by Taskana.
the class UpdateTaskAccTest method testUpdateOfWorkbasketKeyWhatIsNotAllowed.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test(expected = InvalidArgumentException.class)
public void testUpdateOfWorkbasketKeyWhatIsNotAllowed() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
((TaskImpl) task).setWorkbasketKey("USER_2_2");
taskService.updateTask(task);
}
use of pro.taskana.impl.TaskImpl in project taskana by Taskana.
the class TaskServiceImplIntExplicitTest method shouldNotTransferByFailingSecurity.
@WithAccessId(userName = "User", groupNames = { "businessadmin" })
@Test
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException, TaskNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
final String user = "User";
// Set up Security for this Test
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, true);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
classificationService = taskanaEngine.getClassificationService();
workbasketService = taskanaEngine.getWorkbasketService();
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification);
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("wbKey1", "DOMAIN_A");
wb.setName("BASE WB");
wb.setDescription("Normal base WB");
wb.setOwner(user);
wb.setType(WorkbasketType.GROUP);
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoAppend", "DOMAIN_B");
wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
wbNoAppend.setOwner(user);
wbNoAppend.setType(WorkbasketType.CLEARANCE);
wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoTransfer", "DOMAIN_A");
wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
wbNoTransfer.setOwner(user);
wbNoTransfer.setType(WorkbasketType.GROUP);
wbNoTransfer = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoTransfer);
createWorkbasketWithSecurity(wbNoTransfer, wbNoTransfer.getOwner(), true, true, true, false);
TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getId());
task.setName("Task Name");
task.setDescription("Task used for transfer Test");
task.setOwner(user);
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = (TaskImpl) taskServiceImpl.createTask(task);
// Check failing with missing APPEND
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wbNoAppend.getId());
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("APPEND")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
assertThat(task.getWorkbasketKey(), equalTo(wb.getKey()));
}
// Check failing with missing TRANSFER
task.setId("");
task.setWorkbasketKey(wbNoTransfer.getKey());
task.getWorkbasketSummaryImpl().setId(wbNoTransfer.getId());
task = (TaskImpl) taskServiceImpl.createTask(task);
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wb.getId());
fail("Transfer Task should be FAILD, because there are no TRANSFER-Rights on current WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("TRANSFER")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on current WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
}
}
Aggregations