Skip to content

Commit

Permalink
Fixed listRooms recursive logic
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Oct 20, 2023
1 parent 9d4f6f4 commit 3891f20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public List<Session> listAllSessions() {
ListSessionsResponse response = listSessions(initialRequest);
List<Session> responseSessions = response.getSessions();

if (response.getTotalItems() < response.getPageSize()) {
if (response.getTotalItems() <= response.getPageSize()) {
return responseSessions;
}
else if (responseSessions == null) {
Expand Down
15 changes: 7 additions & 8 deletions src/test/java/com/vonage/client/meetings/MeetingsClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1659,16 +1659,11 @@ public void testListAllSessions() throws Exception {
secondJson = "{\n" +
" \"page_size\": 1000,\n" +
" \"total_items\": 1080,\n" +
" \"_embedded\": {\"sessions\":[{},{},{},{},{},{},{\"id\":\"2_T134c5d6c7e8AB0\"},{}]},\n" +
" \"_links\": {\n" +
" \"next\": {\n" +
" \"href\": \"https://api-eu.vonage.com/meetings/rooms?page_size=50&start_id=2235997\"\n" +
" }\n" +
" }\n" +
"}",
" \"_embedded\": {\"sessions\":[{},{},{},{},{},{}," +
" {\"id\":\"2_T134c5d6c7e8AB0\"},{}]},\n" + endLinks,
thirdJson = "{\"total_items\":1002,\"page_size\":1001,\"_embedded\":{\"nonsense\":true}," + endLinks,
fourthJson = "{\"page_size\": 1000,\"_embedded\":{\"sessions\":[]},\n" + endLinks,
fifthJson = "{\"page_size\": 999,\"_embedded\":{\"sessions\":[{}]}}";
fifthJson = "{\"page_size\":999,\"total_items\":999,\"_embedded\":{\"sessions\":[{}]}}";

stubResponse(200, firstJson, secondJson, thirdJson, fourthJson, fifthJson);
List<Session> sessions = client.listAllSessions();
Expand All @@ -1684,6 +1679,10 @@ public void testListAllSessions() throws Exception {
sessions = stubResponseAndGet(thirdJson, client::listAllSessions);
assertNotNull(sessions);
assertEquals(0, sessions.size());

sessions = stubResponseAndGet(fifthJson, client::listAllSessions);
assertNotNull(sessions);
assertEquals(1, sessions.size());
}

@Test
Expand Down

0 comments on commit 3891f20

Please sign in to comment.