use of org.olat.modules.taxonomy.restapi.TaxonomyLevelTypeVO in project OpenOLAT by OpenOLAT.
the class TaxonomyWebServiceTest method getTaxonomyLevelTypes.
@Test
public void getTaxonomyLevelTypes() throws IOException, URISyntaxException {
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-2", "Taxonomy on rest", "Rest is cool", "Ext-tax-1");
TaxonomyLevelType type1 = taxonomyService.createTaxonomyLevelType("RESR-Type-1", "Type 1 on rest", "Type", "EXT-Type-1", taxonomy);
TaxonomyLevelType type2 = taxonomyService.createTaxonomyLevelType("RESR-Type-2", "Type 2 on rest", "Type", "EXT-Type-2", 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").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 (type1.getKey().equals(typeVo.getKey())) {
found1 = true;
} else if (type2.getKey().equals(typeVo.getKey())) {
found2 = true;
}
}
Assert.assertTrue(found1);
Assert.assertTrue(found2);
}
use of org.olat.modules.taxonomy.restapi.TaxonomyLevelTypeVO in project openolat by klemens.
the class TaxonomyWebServiceTest method getTaxonomyLevelTypes.
@Test
public void getTaxonomyLevelTypes() throws IOException, URISyntaxException {
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-2", "Taxonomy on rest", "Rest is cool", "Ext-tax-1");
TaxonomyLevelType type1 = taxonomyService.createTaxonomyLevelType("RESR-Type-1", "Type 1 on rest", "Type", "EXT-Type-1", taxonomy);
TaxonomyLevelType type2 = taxonomyService.createTaxonomyLevelType("RESR-Type-2", "Type 2 on rest", "Type", "EXT-Type-2", 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").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 (type1.getKey().equals(typeVo.getKey())) {
found1 = true;
} else if (type2.getKey().equals(typeVo.getKey())) {
found2 = true;
}
}
Assert.assertTrue(found1);
Assert.assertTrue(found2);
}
use of org.olat.modules.taxonomy.restapi.TaxonomyLevelTypeVO in project openolat by klemens.
the class TaxonomyWebServiceTest method putTaxonomyLevelType.
@Test
public void putTaxonomyLevelType() throws IOException, URISyntaxException {
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-2", "Taxonomy on rest", "Rest is cool", "Ext-tax-1");
dbInstance.commitAndCloseSession();
Assert.assertNotNull(taxonomy);
TaxonomyLevelTypeVO newTypeVo = new TaxonomyLevelTypeVO();
String identifier = UUID.randomUUID().toString();
newTypeVo.setIdentifier(identifier);
newTypeVo.setDisplayName("REST-Type-5");
newTypeVo.setDescription("Unused description");
newTypeVo.setExternalId("EXT-type-5");
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("types").build();
HttpPut method = conn.createPut(request, MediaType.APPLICATION_JSON, true);
conn.addJsonEntity(method, newTypeVo);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
TaxonomyLevelTypeVO typeVo = conn.parse(response, TaxonomyLevelTypeVO.class);
Assert.assertNotNull(typeVo);
Assert.assertEquals(identifier, typeVo.getIdentifier());
Assert.assertEquals("REST-Type-5", typeVo.getDisplayName());
Assert.assertEquals("Unused description", typeVo.getDescription());
Assert.assertEquals("EXT-type-5", typeVo.getExternalId());
}
Aggregations