use of pro.taskana.Classification in project taskana by Taskana.
the class ClassificationServiceImplIntExplicitTest method testDefaultSettingsWithClassificationQuery.
@Test
public void testDefaultSettingsWithClassificationQuery() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Classification classification = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
classification = classificationService.createClassification(classification);
Classification classification1 = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
classification1 = classificationService.createClassification(classification1);
classification1.setParentId(classification.getId());
classification1 = classificationService.updateClassification(classification1);
List<ClassificationSummary> list = classificationService.createClassificationQuery().parentIdIn("").list();
Assert.assertEquals(3, list.size());
list = classificationService.createClassificationQuery().list();
Assert.assertEquals(4, list.size());
connection.commit();
list = classificationService.createClassificationQuery().validInDomainEquals(true).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().createdWithin(today()).list();
Assert.assertEquals(4, list.size());
list = classificationService.createClassificationQuery().domainIn("DOMAIN_C").validInDomainEquals(false).list();
Assert.assertEquals(0, list.size());
list = classificationService.createClassificationQuery().keyIn(classification1.getKey()).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().parentIdIn(classification.getId()).list();
Assert.assertEquals(1, list.size());
assertThat(list.get(0).getKey(), equalTo(classification1.getKey()));
connection.commit();
}
use of pro.taskana.Classification in project taskana by Taskana.
the class ClassificationServiceImplIntExplicitTest method testInsertClassification.
@Test
public void testInsertClassification() throws SQLException, ClassificationNotFoundException, ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
final String domain = "DOMAIN_A";
final String key = "dummy-key";
ClassificationImpl expectedClassification;
Classification actualClassification;
Classification actualClassification2;
// empty classification (root)
expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey("", "TASK");
expectedClassification = (ClassificationImpl) classificationService.createClassification(expectedClassification);
connection.commit();
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.createNewClassificationWithUniqueKey(domain, "TASK");
expectedClassification.setKey(key);
expectedClassification = (ClassificationImpl) classificationService.createClassification(expectedClassification);
connection.commit();
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.createNewClassificationWithUniqueKey(domain, "TASK");
expectedClassification.setKey(key);
classificationService.createClassification(expectedClassification);
connection.commit();
fail("Should have thrown 'ClassificationAlreadyExistException' here.");
} catch (ClassificationAlreadyExistException e) {
}
// new classification but root existing
expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey("", "TASK");
expectedClassification.setKey(key);
expectedClassification.setDomain("DOMAIN_B");
classificationService.createClassification(expectedClassification);
connection.commit();
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));
Classification rootResult = classificationService.getClassification(key, "");
assertThat(rootResult, not(equalTo(null)));
// invalid serviceLevel
try {
expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey("", "TASK");
expectedClassification.setDomain(domain);
expectedClassification.setKey("");
expectedClassification.setServiceLevel("ASAP");
classificationService.createClassification(expectedClassification);
connection.commit();
fail("Should have thrown IllegalArgumentException, because ServiceLevel is invalid.");
} catch (InvalidArgumentException e) {
}
}
use of pro.taskana.Classification in project taskana by Taskana.
the class ClassificationServiceImplIntExplicitTest method testFindAllClassifications.
@Test
public void testFindAllClassifications() throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Classification classification0 = this.createNewClassificationWithUniqueKey("", "TASK");
classificationService.createClassification(classification0);
Classification classification1 = this.createNewClassificationWithUniqueKey("", "TASK");
classificationService.createClassification(classification1);
Classification classification2 = this.createNewClassificationWithUniqueKey("", "TASK");
classification2.setParentId(classification0.getId());
classificationService.createClassification(classification2);
Assert.assertEquals(2 + 1, classificationService.createClassificationQuery().list().size());
connection.commit();
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplIntExplicitTest method should_ReturnList_when_BuilderIsUsed.
@WithAccessId(userName = "Elena", groupNames = { "DummyGroup", "businessadmin" })
@Test
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException, WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
generateSampleAccessItems();
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
workbasket.setName("workbasket");
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
classificationService.createClassification(classification);
// set id manually for authorization tests
workbasket.setId("1");
workbasket.setType(WorkbasketType.GROUP);
workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket);
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
List<TaskSummary> results = taskServiceImpl.createTaskQuery().nameIn("bla", "test").descriptionLike("test").priorityIn(1, 2, 2).stateIn(TaskState.CLAIMED).workbasketKeyDomainIn(new KeyDomain("k1", "DOMAIN_A")).ownerIn("test", "test2", "bla").customAttributeLike("13", "test").classificationKeyIn("pId1", "pId2").primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh").primaryObjectReferenceSystemIn("sys").primaryObjectReferenceTypeIn("type1", "type2").primaryObjectReferenceSystemInstanceIn("sysInst1", "sysInst2").primaryObjectReferenceValueIn("val1", "val2", "val3").list();
Assert.assertEquals(0, results.size());
connection.commit();
}
use of pro.taskana.Classification 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);
}
Aggregations