use of org.olat.restapi.support.vo.CatalogEntryVO in project openolat by klemens.
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();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project openolat by klemens.
the class CatalogTest method testUpdateCatalogEntryQuery.
@Test
public void testUpdateCatalogEntryQuery() 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-b"), new BasicNameValuePair("description", "Entry-description-2-b"), 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-b", updatedEntry.getName());
assertEquals("Entry-description-2-b", updatedEntry.getDescription());
conn.shutdown();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project openolat by klemens.
the class CatalogTest method testPutCatalogEntryJson.
@Test
public void testPutCatalogEntryJson() throws IOException, URISyntaxException {
RepositoryEntry re = createRepository("put-cat-entry-json", 6458438l);
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
CatalogEntryVO subEntry = new CatalogEntryVO();
subEntry.setName("Sub-entry-1");
subEntry.setDescription("Sub-entry-description-1");
subEntry.setType(CatalogEntry.TYPE_NODE);
subEntry.setRepositoryEntryKey(re.getKey());
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
method.addHeader("Content-Type", MediaType.APPLICATION_JSON);
conn.addJsonEntity(method, subEntry);
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();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project openolat by klemens.
the class CatalogTest method testPutCategoryQuery.
@Test
public void testPutCategoryQuery() throws IOException, URISyntaxException {
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)).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);
boolean saved = false;
for (CatalogEntry child : children) {
if (vo.getKey().equals(child.getKey())) {
saved = true;
break;
}
}
assertTrue(saved);
conn.shutdown();
}
use of org.olat.restapi.support.vo.CatalogEntryVO in project openolat by klemens.
the class CatalogVOFactory method get.
public static CatalogEntryVO get(CatalogEntry entry) {
CatalogEntryVO vo = new CatalogEntryVO();
vo.setKey(entry.getKey());
vo.setName(entry.getName());
vo.setDescription(entry.getDescription());
vo.setExternalURL(entry.getExternalURL());
vo.setType(entry.getType());
vo.setParentKey(entry.getParent() == null ? null : entry.getParent().getKey());
vo.setRepositoryEntryKey(entry.getRepositoryEntry() == null ? null : entry.getRepositoryEntry().getKey());
return vo;
}
Aggregations