use of org.olat.commons.calendar.restapi.EventVOes in project OpenOLAT by OpenOLAT.
the class CalendarTest method testGetEvents_paging.
@Test
public void testGetEvents_paging() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login(id1.getName(), "A6B7C8"));
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("calendars").path("events").queryParam("start", "0").queryParam("limit", "5").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
EventVOes voes = conn.parse(response, EventVOes.class);
assertNotNull(voes);
assertTrue(10 <= voes.getTotalCount());
assertNotNull(voes.getEvents());
assertEquals(5, voes.getEvents().length);
// check reliability of api
URI uriOverflow = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("calendars").path("events").queryParam("start", voes.getTotalCount()).queryParam("limit", "5").build();
HttpGet methodOverflow = conn.createGet(uriOverflow, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse responseOverflow = conn.execute(methodOverflow);
assertEquals(200, responseOverflow.getStatusLine().getStatusCode());
EventVOes voesOverflow = conn.parse(responseOverflow, EventVOes.class);
assertNotNull(voesOverflow);
assertNotNull(voesOverflow.getEvents());
assertEquals(0, voesOverflow.getEvents().length);
conn.shutdown();
}
use of org.olat.commons.calendar.restapi.EventVOes in project OpenOLAT by OpenOLAT.
the class CalendarTest method testGetCalendarEvents_paging.
@Test
public void testGetCalendarEvents_paging() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login(id1.getName(), "A6B7C8"));
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("calendars").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<CalendarVO> vos = parseArray(response);
assertNotNull(vos);
// course1 + personal
assertTrue(2 <= vos.size());
CalendarVO calendar = getCourseCalendar(vos, course1);
URI eventUri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("calendars").path(calendar.getId()).path("events").queryParam("start", "0").queryParam("limit", "5").queryParam("onlyFuture", "true").build();
HttpGet eventMethod = conn.createGet(eventUri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse eventResponse = conn.execute(eventMethod);
assertEquals(200, eventResponse.getStatusLine().getStatusCode());
EventVOes events = conn.parse(eventResponse, EventVOes.class);
assertNotNull(events);
assertEquals(10, events.getTotalCount());
assertNotNull(events.getEvents());
assertEquals(5, events.getEvents().length);
conn.shutdown();
}
use of org.olat.commons.calendar.restapi.EventVOes in project openolat by klemens.
the class CalendarTest method testGetCalendarEvents_paging.
@Test
public void testGetCalendarEvents_paging() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login(id1.getName(), "A6B7C8"));
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("calendars").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<CalendarVO> vos = parseArray(response);
assertNotNull(vos);
// course1 + personal
assertTrue(2 <= vos.size());
CalendarVO calendar = getCourseCalendar(vos, course1);
URI eventUri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("calendars").path(calendar.getId()).path("events").queryParam("start", "0").queryParam("limit", "5").queryParam("onlyFuture", "true").build();
HttpGet eventMethod = conn.createGet(eventUri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse eventResponse = conn.execute(eventMethod);
assertEquals(200, eventResponse.getStatusLine().getStatusCode());
EventVOes events = conn.parse(eventResponse, EventVOes.class);
assertNotNull(events);
assertEquals(10, events.getTotalCount());
assertNotNull(events.getEvents());
assertEquals(5, events.getEvents().length);
conn.shutdown();
}
use of org.olat.commons.calendar.restapi.EventVOes in project openolat by klemens.
the class CalendarTest method testGetEvents_paging.
@Test
public void testGetEvents_paging() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login(id1.getName(), "A6B7C8"));
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("calendars").path("events").queryParam("start", "0").queryParam("limit", "5").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
EventVOes voes = conn.parse(response, EventVOes.class);
assertNotNull(voes);
assertTrue(10 <= voes.getTotalCount());
assertNotNull(voes.getEvents());
assertEquals(5, voes.getEvents().length);
// check reliability of api
URI uriOverflow = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("calendars").path("events").queryParam("start", voes.getTotalCount()).queryParam("limit", "5").build();
HttpGet methodOverflow = conn.createGet(uriOverflow, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse responseOverflow = conn.execute(methodOverflow);
assertEquals(200, responseOverflow.getStatusLine().getStatusCode());
EventVOes voesOverflow = conn.parse(responseOverflow, EventVOes.class);
assertNotNull(voesOverflow);
assertNotNull(voesOverflow.getEvents());
assertEquals(0, voesOverflow.getEvents().length);
conn.shutdown();
}
Aggregations