Search in sources :

Example 6 with WorkbasketImpl

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

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

the class TaskServiceImplIntExplicitTest method testStartTransactionFail.

@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test(expected = TaskNotFoundException.class)
public void testStartTransactionFail() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    generateSampleAccessItems();
    WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
    workbasket.setName("workbasket");
    // workbasket.setId("1 "); // set id manually for authorization tests
    // set id manually for authorization tests
    workbasket.setId("1");
    workbasket.setType(WorkbasketType.GROUP);
    Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
    taskanaEngineImpl.getWorkbasketService().createWorkbasket(workbasket);
    taskanaEngineImpl.getClassificationService().createClassification(classification);
    connection.commit();
    Task task = taskServiceImpl.newTask(workbasket.getId());
    task.setName("Unit Test Task");
    task.setClassificationKey(classification.getKey());
    task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
    task = taskServiceImpl.createTask(task);
    connection.commit();
    task = taskServiceImpl.getTask(task.getId());
    TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
    TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
    taskServiceImpl2.getTask(workbasket.getId());
    connection.commit();
}
Also used : Task(pro.taskana.Task) Classification(pro.taskana.Classification) Connection(java.sql.Connection) TaskanaEngineImpl(pro.taskana.impl.TaskanaEngineImpl) TaskServiceImpl(pro.taskana.impl.TaskServiceImpl) WorkbasketImpl(pro.taskana.impl.WorkbasketImpl) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 8 with WorkbasketImpl

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

the class TaskanaTestController method createWorkBasket.

private Workbasket createWorkBasket(String key, String name) throws NotAuthorizedException {
    WorkbasketImpl workbasket = (WorkbasketImpl) taskanaEngine.getWorkbasketService().newWorkbasket(key, "DOMAIN_A");
    String id1 = IdGenerator.generateWithPrefix("TWB");
    workbasket.setId(id1);
    workbasket.setName(name);
    workbasket.setType(WorkbasketType.GROUP);
    return workbasket;
}
Also used : WorkbasketImpl(pro.taskana.impl.WorkbasketImpl)

Example 9 with WorkbasketImpl

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

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

the class WorkbasketServiceImplIntAutocommitTest method updateModifiedTimestamps.

private void updateModifiedTimestamps(Workbasket basket2, Workbasket basket3, Workbasket basket4, Workbasket basket1) {
    // created and modified timestamps are set by WorkbasketServiceImpl to 'now' when the workbasket is created
    // in order to create timestamps distict from the current time, we must use the mapper directly to bypass
    // WorkbasketServiceImpl
    TaskanaEngineProxyForTest engineProxy = new TaskanaEngineProxyForTest(taskanaEngineImpl);
    SqlSession session = engineProxy.getSqlSession();
    WorkbasketMapper mapper = session.getMapper(WorkbasketMapper.class);
    WorkbasketImpl wb1 = (WorkbasketImpl) basket1;
    WorkbasketImpl wb2 = (WorkbasketImpl) basket2;
    WorkbasketImpl wb3 = (WorkbasketImpl) basket3;
    WorkbasketImpl wb4 = (WorkbasketImpl) basket4;
    engineProxy.openConnection();
    wb1.setModified(now.minus(Duration.ofDays(10L)));
    mapper.update(wb1);
    wb2.setModified(now.minus(Duration.ofDays(15L)));
    mapper.update(wb2);
    wb3.setModified(now.minus(Duration.ofDays(20L)));
    mapper.update(wb3);
    wb4.setModified(now.minus(Duration.ofDays(30L)));
    mapper.update(wb4);
    engineProxy.returnConnection();
}
Also used : WorkbasketMapper(pro.taskana.mappings.WorkbasketMapper) SqlSession(org.apache.ibatis.session.SqlSession) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) WorkbasketImpl(pro.taskana.impl.WorkbasketImpl)

Aggregations

WorkbasketImpl (pro.taskana.impl.WorkbasketImpl)13 Test (org.junit.Test)7 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)6 Task (pro.taskana.Task)5 WithAccessId (pro.taskana.security.WithAccessId)5 ClassificationImpl (pro.taskana.impl.ClassificationImpl)4 TaskImpl (pro.taskana.impl.TaskImpl)4 Connection (java.sql.Connection)3 Classification (pro.taskana.Classification)3 Workbasket (pro.taskana.Workbasket)3 TaskanaEngineConfiguration (pro.taskana.configuration.TaskanaEngineConfiguration)2 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)2 SqlSession (org.apache.ibatis.session.SqlSession)1 KeyDomain (pro.taskana.KeyDomain)1 TaskSummary (pro.taskana.TaskSummary)1 TaskServiceImpl (pro.taskana.impl.TaskServiceImpl)1 TaskanaEngineImpl (pro.taskana.impl.TaskanaEngineImpl)1 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)1 WorkbasketMapper (pro.taskana.mappings.WorkbasketMapper)1 WorkbasketResource (pro.taskana.rest.resource.WorkbasketResource)1