use of org.olat.modules.fo.restapi.ForumVO in project openolat by klemens.
the class UserMgmtTest method testUserForums.
@Test
public void testUserForums() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login(id1.getName(), "A6B7C8"));
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("forums").queryParam("start", 0).queryParam("limit", 20).build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
ForumVOes forums = conn.parse(response, ForumVOes.class);
assertNotNull(forums);
assertNotNull(forums.getForums());
assertTrue(forums.getForums().length > 0);
for (ForumVO forum : forums.getForums()) {
Long groupKey = forum.getGroupKey();
if (groupKey != null) {
BusinessGroup bg = businessGroupService.loadBusinessGroup(groupKey);
assertNotNull(bg);
CollaborationTools bgCTSMngr = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
assertTrue(bgCTSMngr.isToolEnabled(CollaborationTools.TOOL_FORUM));
assertNotNull(forum.getForumKey());
assertEquals(bg.getName(), forum.getName());
assertEquals(bg.getKey(), forum.getGroupKey());
assertTrue(businessGroupService.isIdentityInBusinessGroup(id1, bg));
} else {
assertNotNull(forum.getCourseKey());
}
}
conn.shutdown();
}
Aggregations