Search in sources :

Example 1 with TaxonomyVO

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());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyVO(org.olat.modules.taxonomy.restapi.TaxonomyVO) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Example 2 with TaxonomyVO

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());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyVO(org.olat.modules.taxonomy.restapi.TaxonomyVO) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Aggregations

URI (java.net.URI)2 HttpResponse (org.apache.http.HttpResponse)2 HttpGet (org.apache.http.client.methods.HttpGet)2 Test (org.junit.Test)2 Taxonomy (org.olat.modules.taxonomy.Taxonomy)2 TaxonomyVO (org.olat.modules.taxonomy.restapi.TaxonomyVO)2