use of org.olat.modules.taxonomy.restapi.TaxonomyVO in project openolat by klemens.
the class TaxonomyWebServiceTest method getTaxonomy.
@Test
public void getTaxonomy() throws IOException, URISyntaxException {
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-1", "Taxonomy on rest", "Rest is cool", "Ext-tax-1");
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()).build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
TaxonomyVO taxonomyVO = conn.parse(response, TaxonomyVO.class);
Assert.assertNotNull(taxonomyVO);
Assert.assertEquals(taxonomy.getKey(), taxonomyVO.getKey());
Assert.assertEquals("REST-Tax-1", taxonomyVO.getIdentifier());
Assert.assertEquals("Taxonomy on rest", taxonomyVO.getDisplayName());
Assert.assertEquals("Rest is cool", taxonomyVO.getDescription());
Assert.assertEquals("Ext-tax-1", taxonomyVO.getExternalId());
}
use of org.olat.modules.taxonomy.restapi.TaxonomyVO in project OpenOLAT by OpenOLAT.
the class TaxonomyWebServiceTest method getTaxonomy.
@Test
public void getTaxonomy() throws IOException, URISyntaxException {
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-1", "Taxonomy on rest", "Rest is cool", "Ext-tax-1");
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()).build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
TaxonomyVO taxonomyVO = conn.parse(response, TaxonomyVO.class);
Assert.assertNotNull(taxonomyVO);
Assert.assertEquals(taxonomy.getKey(), taxonomyVO.getKey());
Assert.assertEquals("REST-Tax-1", taxonomyVO.getIdentifier());
Assert.assertEquals("Taxonomy on rest", taxonomyVO.getDisplayName());
Assert.assertEquals("Rest is cool", taxonomyVO.getDescription());
Assert.assertEquals("Ext-tax-1", taxonomyVO.getExternalId());
}
Aggregations