use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplTest method testUpdateTaskAddingValidAttachmentTwice.
@Test
public void testUpdateTaskAddingValidAttachmentTwice() throws TaskNotFoundException, SystemException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
Classification classification = createDummyClassification();
Workbasket wb = createWorkbasket("WB-ID", "WB-Key");
Attachment attachment = JunitHelper.createDefaultAttachment();
ObjectReference objectReference = JunitHelper.createDefaultObjRef();
TaskImpl taskBeforeAttachment = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
TaskImpl task = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
taskBeforeAttachment.setModified(null);
taskBeforeAttachment.setCreated(Instant.now());
task.setModified(null);
task.setCreated(taskBeforeAttachment.getCreated());
task.setPrimaryObjRef(objectReference);
task.addAttachment(attachment);
task.addAttachment(attachment);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doReturn(taskBeforeAttachment).when(cutSpy).getTask(task.getId());
Task actualTask = cutSpy.updateTask(task);
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment));
verify(taskanaEngineMock, times(1)).returnConnection();
assertThat(actualTask.getAttachments().size(), equalTo(1));
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplTest method testUpdateTaskUpdateAttachment.
@Test
public void testUpdateTaskUpdateAttachment() throws TaskNotFoundException, SystemException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
String channelUpdate = "OTHER CHANNEL";
Classification classification = createDummyClassification();
Workbasket wb = createWorkbasket("WB-ID", "WB-Key");
Attachment attachment = JunitHelper.createDefaultAttachment();
Attachment attachmentToUpdate = JunitHelper.createDefaultAttachment();
attachmentToUpdate.setChannel(channelUpdate);
ObjectReference objectReference = JunitHelper.createDefaultObjRef();
TaskImpl taskBefore = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
taskBefore.addAttachment(attachment);
TaskImpl task = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
taskBefore.setModified(null);
taskBefore.setCreated(Instant.now());
task.setModified(null);
task.setCreated(taskBefore.getCreated());
task.addAttachment(taskBefore.getAttachments().get(0));
task.setPrimaryObjRef(objectReference);
// should override old one and differ at comparison
task.addAttachment(attachmentToUpdate);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doReturn(taskBefore).when(cutSpy).getTask(task.getId());
Task actualTask = cutSpy.updateTask(task);
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
verify(attachmentMapperMock, times(1)).update(((AttachmentImpl) attachmentToUpdate));
verify(taskanaEngineMock, times(1)).returnConnection();
assertThat(actualTask.getAttachments().size(), equalTo(1));
assertThat(actualTask.getAttachments().get(0).getChannel(), equalTo(channelUpdate));
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method should_ReturnList_when_BuilderIsUsed.
@Test
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException, WorkbasketAlreadyExistException, DomainNotFoundException {
Workbasket wb = workbasketService.newWorkbasket("key", "DOMAIN_A");
wb.setName("workbasket");
wb.setType(WorkbasketType.GROUP);
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
taskanaEngine.getClassificationService().createClassification(classification);
Task task = taskServiceImpl.newTask(wb.getKey(), wb.getDomain());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
taskServiceImpl.createTask(task);
List<TaskSummary> results = taskServiceImpl.createTaskQuery().nameIn("bla", "test").descriptionLike("test").priorityIn(1, 2, 2).stateIn(TaskState.CLAIMED).workbasketKeyDomainIn(new KeyDomain("asd", "novatec"), new KeyDomain("asdasdasd", "DOMAIN_A")).ownerIn("test", "test2", "bla").customAttributeIn("16", "test").classificationKeyIn("pId1", "pId2").primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh").primaryObjectReferenceSystemIn("sys").primaryObjectReferenceTypeIn("type1", "type2").primaryObjectReferenceSystemInstanceIn("sysInst1", "sysInst2").primaryObjectReferenceValueIn("val1", "val2", "val3").list();
Assert.assertEquals(0, results.size());
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class CreateTaskAccTest method testSetDomainFromWorkbasket.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testSetDomainFromWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
TaskService taskService = taskanaEngine.getTaskService();
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
Task newTask = taskService.newTask("WBI:100000000000000000000000000000000006");
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()));
assertNotNull(createdTask.getDomain());
assertEquals(workbasket.getDomain(), createdTask.getDomain());
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TransferTaskAccTest method testBulkTransferTaskWithExceptions.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testBulkTransferTaskWithExceptions() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Workbasket wb = taskanaEngine.getWorkbasketService().getWorkbasket("USER_1_1", "DOMAIN_A");
Instant before = Instant.now();
ArrayList<String> taskIdList = new ArrayList<>();
// working
taskIdList.add("TKI:000000000000000000000000000000000006");
// NotAuthorized
taskIdList.add("TKI:000000000000000000000000000000000041");
// InvalidArgument
taskIdList.add("");
// InvalidArgument (added with ""), duplicate
taskIdList.add(null);
// TaskNotFound
taskIdList.add("TKI:000000000000000000000000000000000099");
BulkOperationResults<String, TaskanaException> results = taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIdList);
assertTrue(results.containsErrors());
assertThat(results.getErrorMap().values().size(), equalTo(3));
// react to result
for (String taskId : results.getErrorMap().keySet()) {
TaskanaException ex = results.getErrorForId(taskId);
if (ex instanceof NotAuthorizedException) {
System.out.println("NotAuthorizedException on bulkTransfer for taskId=" + taskId);
} else if (ex instanceof InvalidArgumentException) {
System.out.println("InvalidArgumentException on bulkTransfer for EMPTY/NULL taskId='" + taskId + "'");
} else if (ex instanceof TaskNotFoundException) {
System.out.println("TaskNotFoundException on bulkTransfer for taskId=" + taskId);
} else {
fail("Impossible failure Entry registered");
}
}
Task transferredTask = taskService.getTask("TKI:000000000000000000000000000000000006");
assertNotNull(transferredTask);
assertTrue(transferredTask.isTransferred());
assertFalse(transferredTask.isRead());
assertEquals(TaskState.READY, transferredTask.getState());
assertThat(transferredTask.getWorkbasketKey(), equalTo(wb.getKey()));
assertThat(transferredTask.getDomain(), equalTo(wb.getDomain()));
assertFalse(transferredTask.getModified().isBefore(before));
assertThat(transferredTask.getOwner(), equalTo(null));
transferredTask = taskService.getTask("TKI:000000000000000000000000000000000002");
assertNotNull(transferredTask);
assertFalse(transferredTask.isTransferred());
assertEquals("USER_1_1", transferredTask.getWorkbasketKey());
}
Aggregations