use of pro.taskana.Workbasket in project taskana by Taskana.
the class CreateWorkbasketAccTest method testCreateWorkbasketNotAuthorized.
@WithAccessId(userName = "dummy")
@Test(expected = NotAuthorizedException.class)
public void testCreateWorkbasketNotAuthorized() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("key3", "DOMAIN_A");
workbasket.setName("Megabasket");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
workbasketService.createWorkbasket(workbasket);
fail("NotAuthorizedException should have been thrown");
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class CreateWorkbasketAccTest method testCreateWorkbasketWithInvalidDomain.
@WithAccessId(userName = "user_1_2", groupNames = { "businessadmin" })
@Test(expected = DomainNotFoundException.class)
public void testCreateWorkbasketWithInvalidDomain() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("key3", "UNKNOWN_DOMAIN");
workbasket.setName("Megabasket");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
workbasketService.createWorkbasket(workbasket);
fail("DomainNotFoundException should have been thrown");
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplTest method testUpdateTaskRemovingAttachment.
@Test
public void testUpdateTaskRemovingAttachment() 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 taskBefore = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
taskBefore.setPrimaryObjRef(objectReference);
taskBefore.addAttachment(attachment);
TaskImpl task = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
task.setPrimaryObjRef(objectReference);
taskBefore.setModified(null);
taskBefore.setCreated(Instant.now());
task.setModified(null);
task.setCreated(taskBefore.getCreated());
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)).deleteAttachment(attachment.getId());
verify(taskanaEngineMock, times(1)).returnConnection();
assertThat(actualTask.getAttachments().size(), equalTo(0));
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplTest method testUpdateTaskAddingValidAttachment.
@Test
public void testUpdateTaskAddingValidAttachment() 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);
task.setPrimaryObjRef(objectReference);
task.addAttachment(attachment);
taskBeforeAttachment.setModified(null);
taskBeforeAttachment.setCreated(Instant.now());
task.setModified(null);
task.setCreated(taskBeforeAttachment.getCreated());
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 testUpdateTaskAddingAttachmentWithSameIdForcedUsingingListMethod.
@Test(expected = AttachmentPersistenceException.class)
public void testUpdateTaskAddingAttachmentWithSameIdForcedUsingingListMethod() 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.setAttachments(new ArrayList<>());
task.getAttachments().add(attachment);
task.getAttachments().add(attachment);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doReturn(taskBeforeAttachment).when(cutSpy).getTask(task.getId());
doThrow(PersistenceException.class).when(attachmentMapperMock).insert(any());
try {
cutSpy.updateTask(task);
} catch (AttachmentPersistenceException e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment));
verify(taskanaEngineMock, times(1)).returnConnection();
throw e;
}
}
Aggregations