Search in sources :

Example 6 with TaskImpl

use of pro.taskana.impl.TaskImpl in project taskana by Taskana.

the class TaskServiceImplIntExplicitTest method createManualTaskShouldThrowClassificationNotFoundException.

@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test(expected = ClassificationNotFoundException.class)
public void createManualTaskShouldThrowClassificationNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    generateSampleAccessItems();
    Workbasket wb = workbasketService.newWorkbasket("WB NR.1", "DOMAIN_A");
    wb.setName("dummy-WB");
    wb.setType(WorkbasketType.PERSONAL);
    wb = workbasketService.createWorkbasket(wb);
    this.createWorkbasketWithSecurity(wb, CurrentUserContext.getUserid(), true, true, true, false);
    Classification classification = classificationService.newClassification(UUID.randomUUID().toString(), wb.getDomain(), // not persisted,
    "t1");
    // not found.
    classification.setName("not persisted - so not found.");
    Task task = this.generateDummyTask();
    ((TaskImpl) task).setWorkbasketKey(wb.getKey());
    task.setClassificationKey(classification.getKey());
    taskServiceImpl.createTask(task);
}
Also used : Task(pro.taskana.Task) TaskImpl(pro.taskana.impl.TaskImpl) Classification(pro.taskana.Classification) Connection(java.sql.Connection) Workbasket(pro.taskana.Workbasket) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 7 with TaskImpl

use of pro.taskana.impl.TaskImpl in project taskana by Taskana.

the class TaskServiceImplIntExplicitTest method shouldTransferTaskToOtherWorkbasket.

@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test
public void shouldTransferTaskToOtherWorkbasket() throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, TaskNotFoundException, InterruptedException, TaskAlreadyExistException, SQLException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
    Workbasket sourceWB;
    Workbasket destinationWB;
    WorkbasketImpl wb;
    ClassificationImpl classification;
    TaskImpl task;
    Task resultTask;
    final int sleepTime = 100;
    final String user = CurrentUserContext.getUserid();
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    // Source Workbasket
    wb = (WorkbasketImpl) workbasketService.newWorkbasket("sourceWbKey", "DOMAIN_A");
    wb.setName("Basic-Workbasket");
    wb.setDescription("Just used as base WB for Task here");
    wb.setOwner(user);
    wb.setType(WorkbasketType.PERSONAL);
    sourceWB = workbasketService.createWorkbasket(wb);
    createWorkbasketWithSecurity(wb, wb.getOwner(), false, false, false, false);
    createWorkbasketWithSecurity(sourceWB, sourceWB.getOwner(), true, true, true, true);
    // Destination Workbasket
    wb = (WorkbasketImpl) workbasketService.newWorkbasket("wb2Key", "DOMAIN_A");
    wb.setName("Desination-WorkBasket");
    wb.setDescription("Destination WB where Task should be transfered to");
    wb.setOwner(user);
    wb.setType(WorkbasketType.TOPIC);
    destinationWB = workbasketService.createWorkbasket(wb);
    createWorkbasketWithSecurity(destinationWB, destinationWB.getOwner(), false, true, true, true);
    // 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("KEY");
    task.setOwner(user);
    task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
    task = (TaskImpl) taskServiceImpl.createTask(task);
    // Sleep for modification-timestamp
    Thread.sleep(sleepTime);
    connection.commit();
    resultTask = taskServiceImpl.transfer(task.getId(), destinationWB.getId());
    connection.commit();
    assertThat(resultTask.isRead(), equalTo(false));
    assertThat(resultTask.isTransferred(), equalTo(true));
    assertThat(resultTask.getWorkbasketKey(), equalTo(destinationWB.getKey()));
    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()));
}
Also used : Task(pro.taskana.Task) TaskImpl(pro.taskana.impl.TaskImpl) Connection(java.sql.Connection) WorkbasketImpl(pro.taskana.impl.WorkbasketImpl) Workbasket(pro.taskana.Workbasket) ClassificationImpl(pro.taskana.impl.ClassificationImpl) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 8 with TaskImpl

use of pro.taskana.impl.TaskImpl 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()));
}
Also used : Task(pro.taskana.Task) TaskImpl(pro.taskana.impl.TaskImpl) WorkbasketImpl(pro.taskana.impl.WorkbasketImpl) Workbasket(pro.taskana.Workbasket) ClassificationImpl(pro.taskana.impl.ClassificationImpl) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 9 with TaskImpl

use of pro.taskana.impl.TaskImpl 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 10 with TaskImpl

use of pro.taskana.impl.TaskImpl in project taskana by Taskana.

the class QueryTasksAccTest method testQueryTaskByCustomAttributes.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testQueryTaskByCustomAttributes() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    newTask.setClassificationKey("T2100");
    // about 1 Meg
    Map<String, String> customAttributesForCreate = createSimpleCustomProperties(20000);
    newTask.setCustomAttributes(customAttributesForCreate);
    Task createdTask = taskService.createTask(newTask);
    assertNotNull(createdTask);
    // query the task by custom attributes
    TaskanaEngineProxyForTest engineProxy = new TaskanaEngineProxyForTest((TaskanaEngineImpl) taskanaEngine);
    try {
        SqlSession session = engineProxy.getSqlSession();
        Configuration config = session.getConfiguration();
        if (!config.hasMapper(TaskTestMapper.class)) {
            config.addMapper(TaskTestMapper.class);
        }
        TaskTestMapper mapper = session.getMapper(TaskTestMapper.class);
        engineProxy.openConnection();
        List<TaskImpl> queryResult = mapper.selectTasksByCustomAttributeLike("%Property Value of Property_1339%");
        assertTrue(queryResult.size() == 1);
        Task retrievedTask = queryResult.get(0);
        assertTrue(createdTask.getId().equals(retrievedTask.getId()));
        // verify that the map is correctly retrieved from the database
        Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributes();
        assertNotNull(customAttributesFromDb);
        assertTrue(customAttributesForCreate.equals(customAttributesFromDb));
    } finally {
        engineProxy.returnConnection();
    }
}
Also used : Task(pro.taskana.Task) SqlSession(org.apache.ibatis.session.SqlSession) Configuration(org.apache.ibatis.session.Configuration) TaskService(pro.taskana.TaskService) TaskImpl(pro.taskana.impl.TaskImpl) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) TaskTestMapper(pro.taskana.mappings.TaskTestMapper) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

Test (org.junit.Test)10 TaskImpl (pro.taskana.impl.TaskImpl)10 WithAccessId (pro.taskana.security.WithAccessId)8 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)6 Task (pro.taskana.Task)5 AbstractAccTest (acceptance.AbstractAccTest)4 Classification (pro.taskana.Classification)4 Workbasket (pro.taskana.Workbasket)4 ClassificationImpl (pro.taskana.impl.ClassificationImpl)4 WorkbasketImpl (pro.taskana.impl.WorkbasketImpl)4 Connection (java.sql.Connection)2 TaskService (pro.taskana.TaskService)2 TaskanaEngineConfiguration (pro.taskana.configuration.TaskanaEngineConfiguration)2 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)2 Instant (java.time.Instant)1 Configuration (org.apache.ibatis.session.Configuration)1 SqlSession (org.apache.ibatis.session.SqlSession)1 Attachment (pro.taskana.Attachment)1 TaskServiceImpl (pro.taskana.impl.TaskServiceImpl)1 TaskanaEngineImpl (pro.taskana.impl.TaskanaEngineImpl)1