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()));
}
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();
}
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;
}
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()));
}
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();
}
Aggregations