Search in sources :

Example 6 with ForumVO

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();
}
Also used : ForumVO(org.olat.modules.fo.restapi.ForumVO) BusinessGroup(org.olat.group.BusinessGroup) ForumVOes(org.olat.modules.fo.restapi.ForumVOes) HttpGet(org.apache.http.client.methods.HttpGet) CollaborationTools(org.olat.collaboration.CollaborationTools) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Aggregations

ForumVO (org.olat.modules.fo.restapi.ForumVO)6 URI (java.net.URI)4 HttpResponse (org.apache.http.HttpResponse)4 HttpGet (org.apache.http.client.methods.HttpGet)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)2 INode (org.olat.core.util.nodes.INode)2 Visitor (org.olat.core.util.tree.Visitor)2 ICourse (org.olat.course.ICourse)2 BCCourseNode (org.olat.course.nodes.BCCourseNode)2 FOCourseNode (org.olat.course.nodes.FOCourseNode)2 CourseTreeVisitor (org.olat.course.run.userview.CourseTreeVisitor)2 VisibleTreeFilter (org.olat.course.run.userview.VisibleTreeFilter)2 BusinessGroup (org.olat.group.BusinessGroup)2 ForumVOes (org.olat.modules.fo.restapi.ForumVOes)2 ACService (org.olat.resource.accesscontrol.ACService)2 AccessResult (org.olat.resource.accesscontrol.AccessResult)2 CourseInfoVO (org.olat.restapi.support.vo.CourseInfoVO)2