use of org.olat.restapi.support.vo.CatalogEntryVO in project OpenOLAT by OpenOLAT.
the class CatalogTest method testUpdateCatalogEntryForm.
@Test
public void testUpdateCatalogEntryForm() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry2.getKey().toString()).build();
HttpPost method = conn.createPost(uri, MediaType.APPLICATION_JSON);
conn.addEntity(method, new BasicNameValuePair("name", "Entry-2-c"), new BasicNameValuePair("description", "Entry-description-2-c"), new BasicNameValuePair("type", String.valueOf(CatalogEntry.TYPE_NODE)));
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CatalogEntryVO vo = conn.parse(response, CatalogEntryVO.class);
assertNotNull(vo);
CatalogEntry updatedEntry = catalogManager.loadCatalogEntry(entry2);
assertEquals("Entry-2-c", updatedEntry.getName());
assertEquals("Entry-description-2-c", updatedEntry.getDescription());
conn.shutdown();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project openolat by klemens.
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 klemens.
the class CatalogTest method testUpdateCatalogEntryForm.
@Test
public void testUpdateCatalogEntryForm() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry2.getKey().toString()).build();
HttpPost method = conn.createPost(uri, MediaType.APPLICATION_JSON);
conn.addEntity(method, new BasicNameValuePair("name", "Entry-2-c"), new BasicNameValuePair("description", "Entry-description-2-c"), new BasicNameValuePair("type", String.valueOf(CatalogEntry.TYPE_NODE)));
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CatalogEntryVO vo = conn.parse(response, CatalogEntryVO.class);
assertNotNull(vo);
CatalogEntry updatedEntry = catalogManager.loadCatalogEntry(entry2);
assertEquals("Entry-2-c", updatedEntry.getName());
assertEquals("Entry-description-2-c", updatedEntry.getDescription());
conn.shutdown();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project openolat by klemens.
the class CatalogTest method testMoveCatalogEntryForm.
@Test
public void testMoveCatalogEntryForm() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entryToMove1.getKey().toString()).build();
HttpPost method = conn.createPost(uri, MediaType.APPLICATION_JSON);
conn.addEntity(method, new BasicNameValuePair("newParentKey", subEntry13move.getKey().toString()));
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CatalogEntryVO vo = conn.parse(response, CatalogEntryVO.class);
assertNotNull(vo);
CatalogEntry updatedEntry = catalogManager.loadCatalogEntry(entryToMove1);
assertEquals("Entry-1-to-move", updatedEntry.getName());
assertEquals("Entry-description-1-to-move", updatedEntry.getDescription());
assertNotNull(updatedEntry.getParent());
assertTrue(updatedEntry.getParent().equalsByPersistableKey(subEntry13move));
conn.shutdown();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project openolat by klemens.
the class CatalogTest method testPutCatalogEntryQuery.
@Test
public void testPutCatalogEntryQuery() throws IOException, URISyntaxException {
RepositoryEntry re = createRepository("put-cat-entry-query", 6458439l);
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).queryParam("name", "Sub-entry-2").queryParam("description", "Sub-entry-description-2").queryParam("type", String.valueOf(CatalogEntry.TYPE_NODE)).queryParam("repoEntryKey", re.getKey().toString()).build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CatalogEntryVO vo = conn.parse(response, CatalogEntryVO.class);
assertNotNull(vo);
List<CatalogEntry> children = catalogManager.getChildrenOf(entry1);
CatalogEntry ce = null;
for (CatalogEntry child : children) {
if (vo.getKey().equals(child.getKey())) {
ce = child;
break;
}
}
assertNotNull(ce);
assertNotNull(ce.getRepositoryEntry());
assertEquals(re.getKey(), ce.getRepositoryEntry().getKey());
conn.shutdown();
}
Aggregations