use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplTest method testCreateThrowingAuthorizedOnWorkbasket.
@Test(expected = NotAuthorizedException.class)
public void testCreateThrowingAuthorizedOnWorkbasket() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("", "dummyTask", "1", dummyClassification);
Workbasket dummyWorkbasket = createWorkbasket("2", "k1");
task.setWorkbasketSummary(dummyWorkbasket.asSummary());
doReturn(dummyWorkbasket).when(workbasketServiceMock).getWorkbasket(any());
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(task.getWorkbasketSummary().getId(), WorkbasketPermission.APPEND);
try {
cutSpy.createTask(task);
} catch (NotAuthorizedException e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).getWorkbasket(task.getWorkbasketSummary().getId());
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketSummary().getId(), WorkbasketPermission.APPEND);
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock, classificationServiceImplMock);
throw e;
}
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplTest method testTransferTaskToDestinationWorkbasketWithoutSecurity.
@Test
public void testTransferTaskToDestinationWorkbasketWithoutSecurity() throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, InvalidWorkbasketException, ClassificationNotFoundException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Workbasket destinationWorkbasket = createWorkbasket("2", "k1");
Workbasket sourceWorkbasket = createWorkbasket("47", "key47");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "key47", dummyClassification);
task.setWorkbasketSummary(sourceWorkbasket.asSummary());
task.setRead(true);
doReturn(destinationWorkbasket).when(workbasketServiceMock).getWorkbasket(destinationWorkbasket.getId());
doReturn(sourceWorkbasket).when(workbasketServiceMock).getWorkbasket(sourceWorkbasket.getId());
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
doReturn(task).when(cutSpy).getTask(task.getId());
doNothing().when(taskMapperMock).update(any());
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getId(), WorkbasketPermission.APPEND);
doNothing().when(workbasketServiceMock).checkAuthorization(sourceWorkbasket.getId(), WorkbasketPermission.TRANSFER);
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(), WorkbasketPermission.APPEND);
verify(workbasketServiceMock, times(1)).checkAuthorization(sourceWorkbasket.getId(), WorkbasketPermission.TRANSFER);
verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId());
verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
assertThat(actualTask.isRead(), equalTo(false));
assertThat(actualTask.getState(), equalTo(TaskState.READY));
assertThat(actualTask.isTransferred(), equalTo(true));
assertThat(actualTask.getWorkbasketKey(), equalTo(destinationWorkbasket.getKey()));
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method shouldTransferTaskToOtherWorkbasket.
@Test
public void shouldTransferTaskToOtherWorkbasket() throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, TaskNotFoundException, InterruptedException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Workbasket sourceWB;
Workbasket destinationWB;
WorkbasketImpl wb;
ClassificationImpl classification;
TaskImpl task;
Task resultTask;
final int sleepTime = 100;
// Source Workbasket
wb = (WorkbasketImpl) workbasketService.newWorkbasket("key1", "DOMAIN_A");
wb.setName("Basic-Workbasket");
wb.setDescription("Just used as base WB for Task here");
wb.setType(WorkbasketType.GROUP);
wb.setOwner("The Tester ID");
sourceWB = workbasketService.createWorkbasket(wb);
// Destination Workbasket
wb = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
wb.setName("Desination-WorkBasket");
wb.setType(WorkbasketType.CLEARANCE);
wb.setDescription("Destination WB where Task should be transfered to");
wb.setOwner("The Tester ID");
destinationWB = workbasketService.createWorkbasket(wb);
// Classification required for Task
classification = (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification);
// Task which should be transfered
task = (TaskImpl) taskServiceImpl.newTask(sourceWB.getId());
task.setName("Task Name");
task.setDescription("Task used for transfer Test");
task.setRead(true);
task.setTransferred(false);
task.setModified(null);
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = (TaskImpl) taskServiceImpl.createTask(task);
// Sleep for modification-timestamp
Thread.sleep(sleepTime);
resultTask = taskServiceImpl.transfer(task.getId(), destinationWB.getId());
assertThat(resultTask.isRead(), equalTo(false));
assertThat(resultTask.isTransferred(), equalTo(true));
assertThat(resultTask.getWorkbasketSummary().getId(), equalTo(destinationWB.getId()));
assertThat(resultTask.getModified(), not(equalTo(null)));
assertThat(resultTask.getModified(), not(equalTo(task.getModified())));
assertThat(resultTask.getCreated(), not(equalTo(null)));
assertThat(resultTask.getCreated(), equalTo(task.getCreated()));
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method testStart.
@Test
public void testStart() throws FileNotFoundException, SQLException, TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Workbasket wb = workbasketService.newWorkbasket("workbasket", "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.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
// skanaEngineImpl.getSqlSession().commit(); // needed so that the change is visible in the other session
TaskanaEngine te2 = taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
Task resultTask = taskServiceImpl2.getTask(task.getId());
Assert.assertNotNull(resultTask);
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method testCreateTaskInTaskanaWithDefaultDb.
@Test
public void testCreateTaskInTaskanaWithDefaultDb() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(TaskanaEngineConfiguration.createDefaultDataSource(), false);
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(null, false, false);
TaskanaEngine te = taskanaEngineConfiguration.buildTaskanaEngine();
((TaskanaEngineImpl) te).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
Workbasket wb = workbasketService.newWorkbasket("workbasket", "DOMAIN_A");
wb.setName("workbasket");
wb.setType(WorkbasketType.GROUP);
te.getWorkbasketService().createWorkbasket(wb);
Classification classification = te.getClassificationService().newClassification("TEST", "DOMAIN_A", "TASK");
te.getClassificationService().createClassification(classification);
Task task = taskServiceImpl.newTask(wb.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
Assert.assertNotNull(task);
Assert.assertNotNull(task.getId());
}
Aggregations