use of pro.taskana.impl.ClassificationImpl 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.ClassificationImpl in project taskana by Taskana.
the class ClassificationServiceImplIntAutoCommitTest method testInsertClassifications.
@Test
public void testInsertClassifications() throws Exception {
final String domain = "DOMAIN_A";
final String key = "dummy-key";
ClassificationImpl expectedClassification;
Classification actualClassification;
Classification actualClassification2;
// empty classification (root)
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey("", "TASK");
expectedClassification = (ClassificationImpl) classificationService.createClassification(expectedClassification);
actualClassification = classificationService.getClassification(expectedClassification.getKey(), expectedClassification.getDomain());
assertThat(actualClassification, not(equalTo(null)));
assertThat(actualClassification.getCreated(), not(equalTo(null)));
assertThat(actualClassification.getId(), not(equalTo(null)));
assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
// specific to domain + root
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey(domain, "TASK");
expectedClassification.setKey(key);
expectedClassification = (ClassificationImpl) classificationService.createClassification(expectedClassification);
actualClassification = classificationService.getClassification(expectedClassification.getKey(), expectedClassification.getDomain());
actualClassification2 = classificationService.getClassification(expectedClassification.getKey(), "");
assertThat(actualClassification, not(equalTo(null)));
assertThat(actualClassification.getCreated(), not(equalTo(null)));
assertThat(actualClassification.getId(), not(equalTo(null)));
assertThat(actualClassification.getKey(), equalTo(key));
assertThat(actualClassification.getDomain(), equalTo(domain));
assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
assertThat(actualClassification2, not(equalTo(null)));
assertThat(actualClassification2.getCreated(), not(equalTo(null)));
assertThat(actualClassification2.getId(), not(equalTo(null)));
assertThat(actualClassification2.getId(), not(equalTo(actualClassification.getId())));
assertThat(actualClassification2.getKey(), equalTo(key));
assertThat(actualClassification2.getDomain(), equalTo(""));
assertThat(actualClassification2.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
// does exist already
try {
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey(domain, "TASK");
expectedClassification.setKey(key);
classificationService.createClassification(expectedClassification);
fail("Should have thrown 'ClassificationAlreadyExistException' here.");
} catch (ClassificationAlreadyExistException e) {
}
// new classification but root existing
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey("DOMAIN_B", "TASK");
expectedClassification.setKey(key);
classificationService.createClassification(expectedClassification);
actualClassification = classificationService.getClassification(key, "DOMAIN_B");
assertThat(actualClassification, not(equalTo(null)));
assertThat(actualClassification.getCreated(), not(equalTo(null)));
assertThat(actualClassification.getId(), not(equalTo(null)));
assertThat(actualClassification.getKey(), equalTo(key));
assertThat(actualClassification.getDomain(), equalTo("DOMAIN_B"));
assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
// verify that
Classification rootResults = classificationService.getClassification(key, "");
assertThat(rootResults, not(equalTo(null)));
// invalid serviceLevel
try {
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey(domain, "TASK");
expectedClassification.setKey("");
expectedClassification.setServiceLevel("ASAP");
classificationService.createClassification(expectedClassification);
fail("Should have thrown IllegalArgumentException, because ServiceLevel is invalid.");
} catch (InvalidArgumentException e) {
}
}
use of pro.taskana.impl.ClassificationImpl 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.ClassificationImpl in project taskana by Taskana.
the class ClassificationMapper method toModel.
public Classification toModel(ClassificationResource classificationResource) throws NotAuthorizedException {
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification(classificationResource.domain, classificationResource.key, classificationResource.type);
BeanUtils.copyProperties(classificationResource, classification);
classification.setId(classificationResource.getClassificationId());
classification.setCreated(Instant.parse(classificationResource.getCreated()));
classification.setModified(Instant.parse(classificationResource.getModified()));
return classification;
}
Aggregations