use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method deleteLectureBlock.
@Test
public void deleteLectureBlock() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence config", "Course with absence configuration", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
LectureBlock block = createLectureBlock(entry);
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path(block.getKey().toString()).build();
HttpDelete method = conn.createDelete(uri, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
LectureBlock deletedBlock = lectureService.getLectureBlock(block);
Assert.assertNull(deletedBlock);
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method getLecturesBlock_course.
/**
* Get the list of lecture block through the course.
*
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void getLecturesBlock_course() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence", "Course with absence", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
LectureBlock block = createLectureBlock(entry);
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").path(course.getResourceableId().toString()).path("lectureblocks").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
List<LectureBlockVO> voList = parseLectureBlockArray(response.getEntity().getContent());
Assert.assertNotNull(voList);
Assert.assertEquals(1, voList.size());
LectureBlockVO blockVo = voList.get(0);
Assert.assertEquals(block.getKey(), blockVo.getKey());
Assert.assertEquals(entry.getKey(), blockVo.getRepoEntryKey());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method getLectureBlock.
@Test
public void getLectureBlock() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence config", "Course with absence configuration", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
LectureBlock block = createLectureBlock(entry);
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path(block.getKey().toString()).build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
LectureBlockVO blockVo = conn.parse(response, LectureBlockVO.class);
Assert.assertNotNull(blockVo);
Assert.assertEquals(block.getKey(), blockVo.getKey());
Assert.assertEquals(entry.getKey(), blockVo.getRepoEntryKey());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method removeRepositoryEntryDefaultGroupToLectureBlock.
@Test
public void removeRepositoryEntryDefaultGroupToLectureBlock() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence config", "Course with absence configuration", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
LectureBlock block = createLectureBlock(entry);
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureService.save(block, Collections.singletonList(defGroup));
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path(block.getKey().toString()).path("participants").path("repositoryentry").build();
HttpDelete method = conn.createDelete(uri, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check the database
List<Group> groups = lectureService.getLectureBlockToGroups(block);
Assert.assertNotNull(groups);
Assert.assertEquals(0, groups.size());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method addRepositoryEntryDefaultGroupToLectureBlock.
@Test
public void addRepositoryEntryDefaultGroupToLectureBlock() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence config", "Course with absence configuration", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
LectureBlock block = createLectureBlock(entry);
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path(block.getKey().toString()).path("participants").path("repositoryentry").build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check the database
List<Group> groups = lectureService.getLectureBlockToGroups(block);
Assert.assertNotNull(groups);
Assert.assertEquals(1, groups.size());
Group defGroup = repositoryService.getDefaultGroup(entry);
Assert.assertEquals(defGroup, groups.get(0));
}
Aggregations