use of org.olat.restapi.support.vo.GroupVO in project OpenOLAT by OpenOLAT.
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");
}
use of org.olat.restapi.support.vo.GroupVO in project OpenOLAT by OpenOLAT.
the class GroupMgmtTest method testGetGroupAdmin.
@Test
public void testGetGroupAdmin() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("groups").path(g1.getKey().toString()).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(vo.getKey(), g1.getKey());
}
use of org.olat.restapi.support.vo.GroupVO in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class CourseGroupMgmtTest 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("LeanringGroup");
URI request = UriBuilder.fromUri(getContextURI()).path("/repo/courses/" + courseRepoEntry.getOlatResource().getResourceableId() + "/groups/" + g1.getKey()).build();
HttpPost method = conn.createPost(request, MediaType.APPLICATION_JSON);
conn.addJsonEntity(method, vo);
HttpResponse response = conn.execute(method);
EntityUtils.consume(response.getEntity());
assertTrue(response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201);
BusinessGroup bg = businessGroupService.loadBusinessGroup(g1.getKey());
assertNotNull(bg);
assertEquals(bg.getKey(), vo.getKey());
assertEquals("rest-g1-mod", bg.getName());
assertEquals("rest-g1 description", bg.getDescription());
}
use of org.olat.restapi.support.vo.GroupVO in project OpenOLAT by OpenOLAT.
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();
}
Aggregations