use of org.olat.restapi.support.vo.GroupVO in project OpenOLAT by OpenOLAT.
the class UserMgmtTest method testUserGroup_notManaged.
@Test
public void testUserGroup_notManaged() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
// retrieve free groups
URI request = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("groups").queryParam("managed", "false").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
InputStream body = response.getEntity().getContent();
List<GroupVO> groups = parseGroupArray(body);
assertNotNull(groups);
// g2
assertEquals(1, groups.size());
conn.shutdown();
}
use of org.olat.restapi.support.vo.GroupVO in project OpenOLAT by OpenOLAT.
the class UserMgmtTest method testUserGroup_managed.
@Test
public void testUserGroup_managed() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
// retrieve managed groups
URI request = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("groups").queryParam("managed", "true").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
InputStream body = response.getEntity().getContent();
List<GroupVO> groups = parseGroupArray(body);
assertNotNull(groups);
// g1 and g3
assertEquals(2, groups.size());
conn.shutdown();
}
use of org.olat.restapi.support.vo.GroupVO in project openolat by klemens.
the class CourseGroupMgmtTest method testGetCourseGroup.
@Test
public void testGetCourseGroup() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
Long courseId = courseRepoEntry.getOlatResource().getResourceableId();
URI request = UriBuilder.fromUri(getContextURI()).path("/repo/courses/" + courseId + "/groups/" + g1.getKey()).build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
GroupVO vo = conn.parse(response, GroupVO.class);
assertNotNull(vo);
assertEquals(g1.getKey(), vo.getKey());
}
use of org.olat.restapi.support.vo.GroupVO in project openolat by klemens.
the class CourseGroupMgmtTest method testGetCourseGroups.
@Test
public void testGetCourseGroups() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
Long courseId = courseRepoEntry.getOlatResource().getResourceableId();
URI request = UriBuilder.fromUri(getContextURI()).path("/repo/courses/" + courseId + "/groups").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
InputStream body = response.getEntity().getContent();
List<GroupVO> vos = parseGroupArray(body);
assertNotNull(vos);
// g1, g2, g3, g4
assertEquals(4, vos.size());
List<Long> voKeys = new ArrayList<Long>(4);
for (GroupVO vo : vos) {
voKeys.add(vo.getKey());
}
assertTrue(voKeys.contains(g1.getKey()));
assertTrue(voKeys.contains(g2.getKey()));
assertTrue(voKeys.contains(g3.getKey()));
assertTrue(voKeys.contains(g4.getKey()));
}
use of org.olat.restapi.support.vo.GroupVO in project openolat by klemens.
the class UserMgmtTest method testUserGroup_externalId.
@Test
public void testUserGroup_externalId() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
// retrieve g1
URI request = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("groups").queryParam("externalId", g1externalId).build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
InputStream body = response.getEntity().getContent();
List<GroupVO> groups = parseGroupArray(body);
assertNotNull(groups);
assertEquals(1, groups.size());
assertEquals(g1.getKey(), groups.get(0).getKey());
assertEquals(g1externalId, groups.get(0).getExternalId());
conn.shutdown();
}
Aggregations