use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl in project openolat by klemens.
the class TaxonomyLevelTypeDAOTest method allowSubTypes.
@Test
public void allowSubTypes() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("Tax-type", "Typed taxonomy", "A typed taxonomy", "");
TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-parent", "A type", null, null, taxonomy);
TaxonomyLevelType subType1 = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-sub-1", "A type", null, null, taxonomy);
TaxonomyLevelType subType2 = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-sub-2", "A type", null, null, taxonomy);
dbInstance.commitAndCloseSession();
taxonomyLevelTypeToTypeDao.addAllowedSubType(type, subType1);
taxonomyLevelTypeToTypeDao.addAllowedSubType(type, subType2);
dbInstance.commitAndCloseSession();
TaxonomyLevelTypeImpl reloadedType = (TaxonomyLevelTypeImpl) taxonomyLevelTypeDao.loadTaxonomyLevelTypeByKey(type.getKey());
Assert.assertNotNull(reloadedType.getAllowedTaxonomyLevelSubTypes());
Assert.assertEquals(2, reloadedType.getAllowedTaxonomyLevelSubTypes().size());
Set<TaxonomyLevelTypeToType> allowedTypeSet = reloadedType.getAllowedTaxonomyLevelSubTypes();
List<TaxonomyLevelType> allowedSubTypes = allowedTypeSet.stream().map(t -> t.getAllowedSubTaxonomyLevelType()).collect(Collectors.toList());
Assert.assertTrue(allowedSubTypes.contains(subType1));
Assert.assertTrue(allowedSubTypes.contains(subType2));
}
Aggregations