use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyCompetenceDAOTest method getCompetenceByTaxonomy.
@Test
public void getCompetenceByTaxonomy() {
// make 2 taxonomy trees
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID-27", "Competence", "", null);
TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level taxonomy 1", "A competence", null, null, null, null, taxonomy1);
TaxonomyCompetence competence1 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level1, id, null);
Taxonomy taxonomy2 = taxonomyDao.createTaxonomy("ID-28", "Competence", "", null);
TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-2", "Competence level taxonomy 2", "A competence", null, null, null, null, taxonomy2);
TaxonomyCompetence competence2 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, id, null);
dbInstance.commitAndCloseSession();
// check the competences of the 2 taxonomy trees
List<TaxonomyCompetence> loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date());
Assert.assertNotNull(loadedCompetences1);
Assert.assertEquals(1, loadedCompetences1.size());
Assert.assertEquals(competence1, loadedCompetences1.get(0));
List<TaxonomyCompetence> loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date());
Assert.assertNotNull(loadedCompetences2);
Assert.assertEquals(1, loadedCompetences2.size());
Assert.assertEquals(competence2, loadedCompetences2.get(0));
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyCompetenceDAOTest method hasCompetenceByTaxonomy_competence.
@Test
public void hasCompetenceByTaxonomy_competence() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-30", "Competence", "", null);
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-A", "Competence level", "A competence", null, null, null, null, taxonomy);
TaxonomyCompetence competenceTarget = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level, id, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(competenceTarget);
boolean hasTarget = taxonomyCompetenceDao.hasCompetenceByTaxonomy(taxonomy, id, new Date(), TaxonomyCompetenceTypes.target);
Assert.assertTrue(hasTarget);
boolean hasTeach = taxonomyCompetenceDao.hasCompetenceByTaxonomy(taxonomy, id, new Date(), TaxonomyCompetenceTypes.teach);
Assert.assertFalse(hasTeach);
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyCompetenceDAOTest method getCompetenceByLevel.
@Test
public void getCompetenceByLevel() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-2");
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-25", "Competence", "", null);
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level", "A competence", null, null, null, null, taxonomy);
TaxonomyCompetence competence = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level, id, null);
dbInstance.commitAndCloseSession();
List<TaxonomyCompetence> loadedCompetences = taxonomyCompetenceDao.getCompetenceByLevel(level);
Assert.assertNotNull(loadedCompetences);
Assert.assertEquals(1, loadedCompetences.size());
TaxonomyCompetence loadedCompetence = loadedCompetences.get(0);
Assert.assertNotNull(loadedCompetence);
Assert.assertEquals(competence, loadedCompetence);
Assert.assertEquals(level, competence.getTaxonomyLevel());
Assert.assertEquals(id, competence.getIdentity());
Assert.assertEquals(TaxonomyCompetenceTypes.target, competence.getCompetenceType());
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsIsManager.
@Test
public void shouldGetItemsIsManager() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("QPool", "QPool", "", null);
TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
TaxonomyLevel taxonomySubLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, taxonomyLevel, null, taxonomy);
Identity ownerAndManager = createRandomIdentity();
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.manage, taxonomyLevel, ownerAndManager, null);
Identity manager = createRandomIdentity();
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.manage, taxonomyLevel, manager, null);
Identity noManager = createRandomIdentity();
QuestionItemImpl item11 = createRandomItem(ownerAndManager);
item11.setTaxonomyLevel(taxonomyLevel);
QuestionItemImpl item12 = createRandomItem(ownerAndManager);
item12.setTaxonomyLevel(taxonomySubLevel);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(ownerAndManager, null);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isManager()).isTrue();
assertThat(filterByKey(loadedItems, item12).isManager()).isTrue();
params = new SearchQuestionItemParams(ownerAndManager, null);
loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isManager()).isTrue();
assertThat(filterByKey(loadedItems, item12).isManager()).isTrue();
params = new SearchQuestionItemParams(noManager, null);
loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isManager()).isFalse();
assertThat(filterByKey(loadedItems, item12).isManager()).isFalse();
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsFilteredByWithoutTaxonomyLevel.
@Test
public void shouldGetItemsFilteredByWithoutTaxonomyLevel() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("QPool", "QPool", "", null);
TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
TaxonomyLevel taxonomySubLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, taxonomyLevel, null, taxonomy);
TaxonomyLevel otherTaxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
QuestionItemImpl item11 = createRandomItem(createRandomIdentity());
item11.setTaxonomyLevel(taxonomyLevel);
QuestionItemImpl item12 = createRandomItem(createRandomIdentity());
item12.setTaxonomyLevel(taxonomySubLevel);
QuestionItemImpl item21 = createRandomItem(createRandomIdentity());
item21.setTaxonomyLevel(otherTaxonomyLevel);
QuestionItem item22 = createRandomItem(createRandomIdentity());
QuestionItem item23 = createRandomItem(createRandomIdentity());
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
params.setWithoutTaxonomyLevelOnly(true);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(loadedItems).hasSize(2);
assertThat(keysOf(loadedItems)).containsOnlyElementsOf(keysOf(item22, item23)).doesNotContainAnyElementsOf(keysOf(item11, item12, item21));
int countItems = qItemQueriesDao.countItems(params);
assertThat(countItems).isEqualTo(2);
}
Aggregations