use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogTest method testAddOwner.
@Test
public void testAddOwner() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).path("owners").path(id1.getKey().toString()).build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CatalogEntry entry = catalogManager.loadCatalogEntry(entry1.getKey());
List<Identity> identities = BaseSecurityManager.getInstance().getIdentitiesOfSecurityGroup(entry.getOwnerGroup());
boolean found = false;
for (Identity identity : identities) {
if (identity.getKey().equals(id1.getKey())) {
found = true;
}
}
assertTrue(found);
conn.shutdown();
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogTest method testRemoveOwner.
@Test
public void testRemoveOwner() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).path("owners").path(id1.getUser().getKey().toString()).build();
HttpDelete method = conn.createDelete(uri, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CatalogEntry entry = catalogManager.loadCatalogEntry(entry1.getKey());
List<Identity> identities = BaseSecurityManager.getInstance().getIdentitiesOfSecurityGroup(entry.getOwnerGroup());
boolean found = false;
for (Identity identity : identities) {
if (identity.getKey().equals(id1.getKey())) {
found = true;
}
}
assertFalse(found);
conn.shutdown();
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogTest method testBasicSecurityPutCall.
@Test
public void testBasicSecurityPutCall() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("rest-catalog-two", "A6B7C8"));
URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).queryParam("name", "Not-sub-entry-3").queryParam("description", "Not-sub-entry-description-3").queryParam("type", String.valueOf(CatalogEntry.TYPE_NODE)).build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(401, response.getStatusLine().getStatusCode());
List<CatalogEntry> children = catalogManager.getChildrenOf(entry1);
boolean saved = false;
for (CatalogEntry child : children) {
if ("Not-sub-entry-3".equals(child.getName())) {
saved = true;
break;
}
}
assertFalse(saved);
conn.shutdown();
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
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.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
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();
}
Aggregations