use of pro.taskana.Classification 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.Classification 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());
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method testWithPrimaryObjectRef.
@Test
public void testWithPrimaryObjectRef() 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());
ObjectReference objRef = new ObjectReference();
objRef.setCompany("novatec");
objRef.setSystem("linux");
objRef.setSystemInstance("inst1");
objRef.setType("fast");
objRef.setValue("4711");
task.setPrimaryObjRef(objRef);
task = taskServiceImpl.createTask(task);
Task task2 = taskServiceImpl.getTask(task.getId());
// skanaEngineImpl.getSqlSession().commit(); // needed so that the change is visible in the other session
Assert.assertNotNull(task2);
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method testStartTransactionFail.
@Test(expected = TaskNotFoundException.class)
public void testStartTransactionFail() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Workbasket wb = workbasketService.newWorkbasket("wb1k1", "DOMAIN_A");
wb.setName("sdf");
wb.setType(WorkbasketType.GROUP);
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
classification = taskanaEngine.getClassificationService().createClassification(classification);
classification = taskanaEngine.getClassificationService().getClassification(classification.getKey(), classification.getDomain());
TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getKey(), "DOMAIN_A");
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
taskServiceImpl.createTask(task);
taskServiceImpl.getTask(task.getId());
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
taskServiceImpl2.getTask(wb.getId());
}
use of pro.taskana.Classification in project taskana by Taskana.
the class ClassificationServiceImplTest method testCreateClassificationParentNotExisting.
@Test(expected = ClassificationNotFoundException.class)
public void testCreateClassificationParentNotExisting() throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
Classification classification = createDummyClassification();
classification.setParentId("NOT EXISTING ID");
doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), classification.getDomain());
doReturn(null).when(classificationMapperMock).findById(classification.getParentId());
doReturn(true).when(taskanaEngineImplMock).domainExists(any());
try {
cutSpy.createClassification(classification);
} catch (ClassificationNotFoundException e) {
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).openConnection();
verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(), classification.getDomain());
verify(cutSpy, times(1)).getClassification(classification.getParentId());
verify(classificationMapperMock, times(1)).findById(classification.getParentId());
verify(taskanaEngineImplMock, times(2)).returnConnection();
verify(taskanaEngineImplMock, times(1)).domainExists(any());
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
throw e;
}
}
Aggregations