Search in sources :

Example 91 with TaxonomyLevelType

use of org.olat.modules.taxonomy.TaxonomyLevelType 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));
}
Also used : TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) List(java.util.List) DB(org.olat.core.commons.persistence.DB) TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Set(java.util.Set) OlatTestCase(org.olat.test.OlatTestCase) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) Assert(org.junit.Assert) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Collectors(java.util.stream.Collectors) Taxonomy(org.olat.modules.taxonomy.Taxonomy) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Test(org.junit.Test)

Example 92 with TaxonomyLevelType

use of org.olat.modules.taxonomy.TaxonomyLevelType in project openolat by klemens.

the class TaxonomyLevelTypeDAOTest method createTaxonomyLevelType.

@Test
public void createTaxonomyLevelType() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("Tax-type", "Typed taxonomy", "A typed taxonomy", "");
    TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-0", "A first type", "Typed", "TYP-0", taxonomy);
    dbInstance.commit();
    Assert.assertNotNull(type);
    Assert.assertNotNull(type.getKey());
    Assert.assertNotNull(type.getCreationDate());
    Assert.assertEquals("Type-0", type.getIdentifier());
    Assert.assertEquals("A first type", type.getDisplayName());
    Assert.assertEquals("Typed", type.getDescription());
    Assert.assertEquals("TYP-0", type.getExternalId());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Test(org.junit.Test)

Aggregations

TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)92 Test (org.junit.Test)40 Taxonomy (org.olat.modules.taxonomy.Taxonomy)32 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)32 ArrayList (java.util.ArrayList)26 Identity (org.olat.core.id.Identity)20 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)16 URI (java.net.URI)14 HttpResponse (org.apache.http.HttpResponse)14 TaxonomyLevelTypeRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl)14 Path (javax.ws.rs.Path)12 List (java.util.List)10 Produces (javax.ws.rs.Produces)10 Collectors (java.util.stream.Collectors)8 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 PUT (javax.ws.rs.PUT)6 HttpGet (org.apache.http.client.methods.HttpGet)6 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6