use of pro.taskana.Classification 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.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testSetTaskReadWIthExistingTask.
@Test
public void testSetTaskReadWIthExistingTask() throws TaskNotFoundException, ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
task.setModified(null);
doReturn(task).when(cutSpy).getTask(task.getId());
doNothing().when(taskMapperMock).update(task);
Task actualTask = cutSpy.setTaskRead("1", true);
verify(taskanaEngineMock, times(1)).openConnection();
verify(taskMapperMock, times(1)).update(task);
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
assertThat(actualTask.getModified(), not(equalTo(null)));
assertThat(actualTask.isRead(), equalTo(true));
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testTransferNotAuthorizationOnWorkbasketAppend.
@Test(expected = NotAuthorizedException.class)
public void testTransferNotAuthorizationOnWorkbasketAppend() throws Exception {
String destinationWorkbasketId = "2";
Classification dummyClassification = createDummyClassification();
Task task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doReturn(task).when(cutSpy).getTask(task.getId());
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId, WorkbasketPermission.APPEND);
try {
cutSpy.transfer(task.getId(), destinationWorkbasketId);
} catch (Exception e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, WorkbasketPermission.APPEND);
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
throw e;
}
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testTransferTaskDoesNotExist.
@Test(expected = TaskNotFoundException.class)
public void testTransferTaskDoesNotExist() throws Exception {
Classification dummyClassification = createDummyClassification();
Task task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
try {
cutSpy.transfer(task.getId(), "2");
} catch (Exception e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
throw e;
}
}
use of pro.taskana.Classification 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));
}
Aggregations