use of org.olat.restapi.support.vo.GroupVO in project OpenOLAT by OpenOLAT.
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();
}
use of org.olat.restapi.support.vo.GroupVO in project openolat by klemens.
the class UserMgmtTest method testUserGroup.
@Test
public void testUserGroup() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
// retrieve all groups
URI request = UriBuilder.fromUri(getContextURI()).path("/users/" + id1.getKey() + "/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> groups = parseGroupArray(body);
assertNotNull(groups);
// g1, g2 and g3
assertEquals(3, groups.size());
conn.shutdown();
}
use of org.olat.restapi.support.vo.GroupVO in project openolat by klemens.
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 klemens.
the class GroupMgmtTest method testCreateCourseGroup.
@Test
public void testCreateCourseGroup() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
GroupVO vo = new GroupVO();
vo.setName("rest-g5-new");
vo.setDescription("rest-g5 description");
vo.setType("BuddyGroup");
URI request = UriBuilder.fromUri(getContextURI()).path("groups").build();
HttpPut method = conn.createPut(request, MediaType.APPLICATION_JSON, true);
conn.addJsonEntity(method, vo);
HttpResponse response = conn.execute(method);
assertTrue(response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201);
GroupVO newGroupVo = conn.parse(response, GroupVO.class);
assertNotNull(newGroupVo);
BusinessGroup bg = businessGroupService.loadBusinessGroup(newGroupVo.getKey());
assertNotNull(bg);
assertEquals(bg.getKey(), newGroupVo.getKey());
assertEquals(bg.getName(), "rest-g5-new");
assertEquals(bg.getDescription(), "rest-g5 description");
}
use of org.olat.restapi.support.vo.GroupVO in project openolat by klemens.
the class GroupMgmtTest method testUpdateCourseGroup.
@Test
public void testUpdateCourseGroup() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
GroupVO vo = new GroupVO();
vo.setKey(g1.getKey());
vo.setName("rest-g1-mod");
vo.setDescription("rest-g1 description");
vo.setMinParticipants(g1.getMinParticipants());
vo.setMaxParticipants(g1.getMaxParticipants());
vo.setType("LearningGroup");
URI request = UriBuilder.fromUri(getContextURI()).path("/groups/" + g1.getKey()).build();
HttpPost method = conn.createPost(request, MediaType.APPLICATION_JSON);
conn.addJsonEntity(method, vo);
HttpResponse response = conn.execute(method);
assertTrue(response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201);
EntityUtils.consume(response.getEntity());
BusinessGroup bg = businessGroupService.loadBusinessGroup(g1.getKey());
assertNotNull(bg);
assertEquals(bg.getKey(), vo.getKey());
assertEquals(bg.getName(), "rest-g1-mod");
assertEquals(bg.getDescription(), "rest-g1 description");
}
Aggregations