Search in sources :

Example 81 with Classification

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);
}
Also used : Task(pro.taskana.Task) TaskanaEngine(pro.taskana.TaskanaEngine) Classification(pro.taskana.Classification) TaskServiceImpl(pro.taskana.impl.TaskServiceImpl) Workbasket(pro.taskana.Workbasket) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 82 with Classification

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());
}
Also used : TaskanaEngineConfiguration(pro.taskana.configuration.TaskanaEngineConfiguration) Task(pro.taskana.Task) TaskanaEngine(pro.taskana.TaskanaEngine) Classification(pro.taskana.Classification) TaskanaEngineImpl(pro.taskana.impl.TaskanaEngineImpl) TaskServiceImpl(pro.taskana.impl.TaskServiceImpl) DBCleaner(pro.taskana.impl.configuration.DBCleaner) Workbasket(pro.taskana.Workbasket) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 83 with Classification

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);
}
Also used : Task(pro.taskana.Task) ObjectReference(pro.taskana.impl.ObjectReference) Classification(pro.taskana.Classification) Workbasket(pro.taskana.Workbasket) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 84 with Classification

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());
}
Also used : TaskImpl(pro.taskana.impl.TaskImpl) Classification(pro.taskana.Classification) TaskanaEngineImpl(pro.taskana.impl.TaskanaEngineImpl) TaskServiceImpl(pro.taskana.impl.TaskServiceImpl) Workbasket(pro.taskana.Workbasket) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 85 with Classification

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;
    }
}
Also used : Classification(pro.taskana.Classification) ClassificationNotFoundException(pro.taskana.exceptions.ClassificationNotFoundException) Test(org.junit.Test)

Aggregations

Classification (pro.taskana.Classification)102 Test (org.junit.Test)88 Task (pro.taskana.Task)32 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)29 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)28 AbstractAccTest (acceptance.AbstractAccTest)23 WithAccessId (pro.taskana.security.WithAccessId)21 ClassificationSummary (pro.taskana.ClassificationSummary)20 Workbasket (pro.taskana.Workbasket)18 Connection (java.sql.Connection)14 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)14 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)13 TaskAlreadyExistException (pro.taskana.exceptions.TaskAlreadyExistException)11 ClassificationService (pro.taskana.ClassificationService)10 AttachmentPersistenceException (pro.taskana.exceptions.AttachmentPersistenceException)10 ConcurrencyException (pro.taskana.exceptions.ConcurrencyException)10 InvalidOwnerException (pro.taskana.exceptions.InvalidOwnerException)10 InvalidStateException (pro.taskana.exceptions.InvalidStateException)10 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)10 SystemException (pro.taskana.exceptions.SystemException)10