use of org.olat.restapi.support.vo.CourseVO in project openolat by klemens.
the class CoursesTest method testGetCourses_searchExternalRef.
@Test
public void testGetCourses_searchExternalRef() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("/repo/courses").queryParam("externalRef", externalRef).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<CourseVO> courses = parseCourseArray(body);
assertNotNull(courses);
assertTrue(courses.size() >= 1);
CourseVO vo = null;
for (CourseVO course : courses) {
if (externalRef.equals(course.getExternalRef())) {
vo = course;
}
}
assertNotNull(vo);
assertEquals(vo.getKey(), course2.getResourceableId());
}
use of org.olat.restapi.support.vo.CourseVO in project openolat by klemens.
the class CoursesTest method testGetCourses_searchExternalID.
@Test
public void testGetCourses_searchExternalID() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("/repo/courses").queryParam("externalId", externalId).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<CourseVO> courses = parseCourseArray(body);
assertNotNull(courses);
assertTrue(courses.size() >= 1);
CourseVO vo = null;
for (CourseVO course : courses) {
if (externalId.equals(course.getExternalId())) {
vo = course;
}
}
assertNotNull(vo);
assertEquals(vo.getKey(), course2.getResourceableId());
}
use of org.olat.restapi.support.vo.CourseVO in project openolat by klemens.
the class CoursesTest method testCreateEmpty_withoutAuthorCourse.
@Test
public void testCreateEmpty_withoutAuthorCourse() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").queryParam("shortTitle", "Course without author").queryParam("title", "Course without author").queryParam("setAuthor", "false").build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
CourseVO courseVo = conn.parse(response, CourseVO.class);
Assert.assertNotNull(courseVo);
Assert.assertEquals("Course without author", courseVo.getTitle());
// load repository entry
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(courseVo.getRepoEntryKey());
Assert.assertNotNull(re);
Assert.assertNotNull(re.getOlatResource());
Assert.assertEquals("Course without author", re.getDisplayname());
// load the course
ICourse course = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
Assert.assertNotNull(course);
Assert.assertEquals("Course without author", course.getCourseTitle());
Assert.assertEquals(re, course.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
// check the list of owners
List<Identity> owners = repositoryEntryRelationDao.getMembers(re, RepositoryEntryRelationType.both, GroupRoles.owner.name());
Assert.assertNotNull(owners);
Assert.assertTrue(owners.isEmpty());
}
use of org.olat.restapi.support.vo.CourseVO in project openolat by klemens.
the class CoursesTest method testGetCourses_managed.
@Test
public void testGetCourses_managed() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("/repo/courses").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<CourseVO> courses = parseCourseArray(body);
assertNotNull(courses);
assertTrue(courses.size() >= 1);
for (CourseVO course : courses) {
boolean managed = StringHelper.containsNonWhitespace(course.getManagedFlags());
Assert.assertTrue(managed);
}
}
use of org.olat.restapi.support.vo.CourseVO in project openolat by klemens.
the class CoursesTest method testCreateEmptyCourse.
@Test
public void testCreateEmptyCourse() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").queryParam("shortTitle", "course3").queryParam("title", "course3 long name").build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CourseVO course = conn.parse(response, CourseVO.class);
assertNotNull(course);
assertEquals("course3", course.getTitle());
// check repository entry
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(course.getRepoEntryKey());
assertNotNull(re);
assertNotNull(re.getOlatResource());
}
Aggregations