use of org.olat.restapi.support.vo.GroupConfigurationVO in project openolat by klemens.
the class GroupMgmtTest method testCreateCourseGroupWithNewsAndContact.
@Test
public void testCreateCourseGroupWithNewsAndContact() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
// create the group
GroupVO vo = new GroupVO();
vo.setName("rest-g7-news");
vo.setDescription("rest-g7 with news");
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);
// update the configuration
GroupConfigurationVO configVo = new GroupConfigurationVO();
configVo.setTools(new String[] { "hasContactForm", "hasNews" });
configVo.setNews("<p>News!</p>");
URI configRequest = UriBuilder.fromUri(getContextURI()).path("groups").path(newGroupVo.getKey().toString()).path("configuration").build();
HttpPost configMethod = conn.createPost(configRequest, MediaType.APPLICATION_JSON);
conn.addJsonEntity(configMethod, configVo);
HttpResponse configResponse = conn.execute(configMethod);
assertTrue(configResponse.getStatusLine().getStatusCode() == 200 || configResponse.getStatusLine().getStatusCode() == 201);
EntityUtils.consume(configResponse.getEntity());
// check group
BusinessGroup bg = businessGroupService.loadBusinessGroup(newGroupVo.getKey());
assertNotNull(bg);
assertEquals(bg.getKey(), newGroupVo.getKey());
assertEquals(bg.getName(), "rest-g7-news");
assertEquals(bg.getDescription(), "rest-g7 with news");
// check collaboration tools configuration
CollaborationTools tools = CollaborationToolsFactory.getInstance().getCollaborationToolsIfExists(bg);
assertNotNull(tools);
assertFalse(tools.isToolEnabled(CollaborationTools.TOOL_FOLDER));
assertTrue(tools.isToolEnabled(CollaborationTools.TOOL_NEWS));
assertFalse(tools.isToolEnabled(CollaborationTools.TOOL_CALENDAR));
assertFalse(tools.isToolEnabled(CollaborationTools.TOOL_CHAT));
assertTrue(tools.isToolEnabled(CollaborationTools.TOOL_CONTACT));
assertFalse(tools.isToolEnabled(CollaborationTools.TOOL_FORUM));
assertFalse(tools.isToolEnabled(CollaborationTools.TOOL_PORTFOLIO));
assertFalse(tools.isToolEnabled(CollaborationTools.TOOL_WIKI));
// Check news tools access configuration
assertEquals("<p>News!</p>", tools.lookupNews());
}
Aggregations