Search in sources :

Example 21 with TaxonomyLevelType

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

the class DocumentPoolManagerTest method hasCompetenceByTaxonomy_have_negative.

@Test
public void hasCompetenceByTaxonomy_have_negative() {
    // create a level and competence with a type teach
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
    TaxonomyLevelType type = createTypeLevelCompetence(id, null, TaxonomyCompetenceTypes.have);
    // set read for teach competence
    type.setDocumentsLibraryTeachCompetenceReadEnabled(true);
    type = taxonomyLevelTypeDao.updateTaxonomyLevelType(type);
    dbInstance.commitAndCloseSession();
    boolean hasCompetence = documentPoolManager.hasValidCompetence(id);
    Assert.assertFalse(hasCompetence);
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 22 with TaxonomyLevelType

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

the class TaxonomyLevelTypeDAOTest method createAndLoadTaxonomyLevelType.

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

Example 23 with TaxonomyLevelType

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

the class TaxonomyLevelTypeDAOTest method loadTaxonomyLevelTypeByTaxonomy.

@Test
public void loadTaxonomyLevelTypeByTaxonomy() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("Tax-type", "Typed taxonomy", "A typed taxonomy", "");
    Taxonomy taxonomyMarker = taxonomyDao.createTaxonomy("Tax-marker", "Marker taxonomy", "An unused taxonomy", "");
    TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-reload", "A first reloaded type", "Typed", "TYP-1", taxonomy);
    dbInstance.commitAndCloseSession();
    // check the taxonomy with types
    List<TaxonomyLevelType> taxonomyTypes = taxonomyLevelTypeDao.loadTaxonomyLevelTypeByTaxonomy(taxonomy);
    Assert.assertNotNull(taxonomyTypes);
    Assert.assertEquals(1, taxonomyTypes.size());
    Assert.assertEquals(type, taxonomyTypes.get(0));
    // check the marker without
    List<TaxonomyLevelType> taxonomyWithoutTypes = taxonomyLevelTypeDao.loadTaxonomyLevelTypeByTaxonomy(taxonomyMarker);
    Assert.assertNotNull(taxonomyWithoutTypes);
    Assert.assertEquals(0, taxonomyWithoutTypes.size());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Test(org.junit.Test)

Example 24 with TaxonomyLevelType

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

the class TaxonomyWebServiceTest method getTaxonomyLevelTypeAllowedSubTypes.

@Test
public void getTaxonomyLevelTypeAllowedSubTypes() throws IOException, URISyntaxException {
    Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-4", "Taxonomy on rest", "Rest is cool", "Ext-tax-1");
    TaxonomyLevelType type = taxonomyService.createTaxonomyLevelType("REST-Type-4", "Type 4 on rest", "Type", "EXT-Type-4", taxonomy);
    TaxonomyLevelType subType1 = taxonomyService.createTaxonomyLevelType("REST-Type-4-1", "Type 4.1 on rest", "Type", "EXT-Type-4-1", taxonomy);
    TaxonomyLevelType subType2 = taxonomyService.createTaxonomyLevelType("REST-Type-4-2", "Type 4.2 on rest", "Type", "EXT-Type-4-2", taxonomy);
    dbInstance.commit();
    List<TaxonomyLevelType> subTypes = new ArrayList<>(2);
    subTypes.add(subType1);
    subTypes.add(subType2);
    type = taxonomyService.updateTaxonomyLevelType(type, subTypes);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(taxonomy);
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("types").path(type.getKey().toString()).path("allowedSubTypes").build();
    HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    List<TaxonomyLevelTypeVO> typeVoList = parseTaxonomyLevelTypesArray(response.getEntity().getContent());
    Assert.assertNotNull(typeVoList);
    Assert.assertEquals(2, typeVoList.size());
    boolean found1 = false;
    boolean found2 = false;
    for (TaxonomyLevelTypeVO typeVo : typeVoList) {
        if (subType1.getKey().equals(typeVo.getKey())) {
            found1 = true;
        } else if (subType2.getKey().equals(typeVo.getKey())) {
            found2 = true;
        }
    }
    Assert.assertTrue(found1);
    Assert.assertTrue(found2);
}
Also used : TaxonomyLevelTypeVO(org.olat.modules.taxonomy.restapi.TaxonomyLevelTypeVO) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) HttpGet(org.apache.http.client.methods.HttpGet) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Example 25 with TaxonomyLevelType

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

the class TaxonomyWebServiceTest method getTaxonomyLevelType.

@Test
public void getTaxonomyLevelType() throws IOException, URISyntaxException {
    Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-2", "Taxonomy on rest", "Rest is cool", "Ext-tax-1");
    TaxonomyLevelType type = taxonomyService.createTaxonomyLevelType("REST-Type-3", "Type 3 on rest", "Type", "EXT-Type-3", taxonomy);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(taxonomy);
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("types").path(type.getKey().toString()).build();
    HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    TaxonomyLevelTypeVO typeVo = conn.parse(response, TaxonomyLevelTypeVO.class);
    Assert.assertNotNull(typeVo);
}
Also used : TaxonomyLevelTypeVO(org.olat.modules.taxonomy.restapi.TaxonomyLevelTypeVO) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) 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