use of org.olat.restapi.support.vo.CatalogEntryVO in project OpenOLAT by OpenOLAT.
the class CatalogTest method testGetChildren.
@Test
public void testGetChildren() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(root1.getKey().toString()).path("children").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
InputStream body = response.getEntity().getContent();
List<CatalogEntryVO> vos = parseEntryArray(body);
assertNotNull(vos);
assertTrue(vos.size() >= 2);
conn.shutdown();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project OpenOLAT by OpenOLAT.
the class CatalogTest method testGetChild.
@Test
public void testGetChild() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CatalogEntryVO vo = conn.parse(response, CatalogEntryVO.class);
assertNotNull(vo);
assertEquals(entry1.getName(), vo.getName());
assertEquals(entry1.getDescription(), vo.getDescription());
conn.shutdown();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project OpenOLAT by OpenOLAT.
the class CatalogTest method testUpdateCatalogEntryJson.
@Test
public void testUpdateCatalogEntryJson() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
CatalogEntryVO entry = new CatalogEntryVO();
entry.setName("Entry-1-b");
entry.setDescription("Entry-description-1-b");
entry.setType(CatalogEntry.TYPE_NODE);
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).build();
HttpPost method = conn.createPost(uri, MediaType.APPLICATION_JSON);
method.addHeader("Content-Type", MediaType.APPLICATION_JSON);
conn.addJsonEntity(method, entry);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CatalogEntryVO vo = conn.parse(response, CatalogEntryVO.class);
assertNotNull(vo);
CatalogEntry updatedEntry = catalogManager.loadCatalogEntry(entry1);
assertEquals("Entry-1-b", updatedEntry.getName());
assertEquals("Entry-description-1-b", updatedEntry.getDescription());
conn.shutdown();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project OpenOLAT by OpenOLAT.
the class CatalogTest method testGetRoots.
@Test
public void testGetRoots() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
InputStream body = response.getEntity().getContent();
List<CatalogEntryVO> vos = parseEntryArray(body);
assertNotNull(vos);
// Root-1
assertEquals(1, vos.size());
conn.shutdown();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project OpenOLAT by OpenOLAT.
the class CatalogTest method testUpdateAndMoveCatalogEntryJson.
@Test
public void testUpdateAndMoveCatalogEntryJson() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
CatalogEntryVO entry = new CatalogEntryVO();
entry.setName("Entry-2-moved-down");
entry.setDescription("Entry-description-2-moved-down");
entry.setType(CatalogEntry.TYPE_NODE);
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entryToMove2.getKey().toString()).queryParam("newParentKey", subEntry13move.getKey().toString()).build();
HttpPost method = conn.createPost(uri, MediaType.APPLICATION_JSON);
method.addHeader("Content-Type", MediaType.APPLICATION_JSON);
conn.addJsonEntity(method, entry);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CatalogEntryVO vo = conn.parse(response, CatalogEntryVO.class);
assertNotNull(vo);
CatalogEntry updatedEntry = catalogManager.loadCatalogEntry(entryToMove2);
assertEquals("Entry-2-moved-down", updatedEntry.getName());
assertEquals("Entry-description-2-moved-down", updatedEntry.getDescription());
assertNotNull(updatedEntry.getParent());
assertTrue(updatedEntry.getParent().equalsByPersistableKey(subEntry13move));
conn.shutdown();
}
Aggregations