use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class DocumentPoolManagerTest method hasCompetenceByTaxonomy_negative.
@Test
public void hasCompetenceByTaxonomy_negative() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
String levelId = "DP-Lev. " + UUID.randomUUID();
Taxonomy taxonomy = getDocumentPoolTaxonomy();
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel(levelId, "Competence level", "A competence", null, null, null, null, taxonomy);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(level);
boolean hasCompetence = documentPoolManager.hasValidCompetence(id);
Assert.assertFalse(hasCompetence);
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyCompetenceDAOTest method hasCompetenceByTaxonomy.
@Test
public void hasCompetenceByTaxonomy() {
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 hasCompetence = taxonomyCompetenceDao.hasCompetenceByTaxonomy(taxonomy, id, new Date());
Assert.assertTrue(hasCompetence);
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyCompetenceDAOTest method getCompetenceByTaxonomyAndCompetenceTypes.
@Test
public void getCompetenceByTaxonomyAndCompetenceTypes() {
// make 2 taxonomy trees
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID-31", "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-32", "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);
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, level2, id, null);
Identity otherId = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, otherId, null);
dbInstance.commitAndCloseSession();
// check the competences of the 2 taxonomy trees
List<TaxonomyCompetence> loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date(), TaxonomyCompetenceTypes.target);
Assert.assertNotNull(loadedCompetences1);
Assert.assertEquals(1, loadedCompetences1.size());
Assert.assertEquals(competence1, loadedCompetences1.get(0));
loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date(), TaxonomyCompetenceTypes.have);
Assert.assertEquals(0, loadedCompetences1.size());
List<TaxonomyCompetence> loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date(), TaxonomyCompetenceTypes.target);
Assert.assertNotNull(loadedCompetences2);
Assert.assertEquals(1, loadedCompetences2.size());
Assert.assertEquals(competence2, loadedCompetences2.get(0));
loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date(), TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach);
Assert.assertEquals(0, loadedCompetences2.size());
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyCompetenceDAOTest method hasCompetenceByLevel_hasOnlyOtherCompetence.
@Test
public void hasCompetenceByLevel_hasOnlyOtherCompetence() {
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);
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level, id, null);
dbInstance.commitAndCloseSession();
boolean hasCompetence = taxonomyCompetenceDao.hasCompetenceByLevel(level, id, new Date(), TaxonomyCompetenceTypes.teach);
Assert.assertFalse(hasCompetence);
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyCompetenceDAOTest method hasCompetenceByTaxonomy_negative.
@Test
public void hasCompetenceByTaxonomy_negative() {
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);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(level);
boolean hasCompetence = taxonomyCompetenceDao.hasCompetenceByTaxonomy(taxonomy, id, new Date());
Assert.assertFalse(hasCompetence);
}
Aggregations