diff --git a/src/main/java/com/vonage/client/meetings/MeetingsClient.java b/src/main/java/com/vonage/client/meetings/MeetingsClient.java index 397b1f334..7a8134c46 100644 --- a/src/main/java/com/vonage/client/meetings/MeetingsClient.java +++ b/src/main/java/com/vonage/client/meetings/MeetingsClient.java @@ -165,7 +165,7 @@ public List listAllSessions() { ListSessionsResponse response = listSessions(initialRequest); List responseSessions = response.getSessions(); - if (response.getTotalItems() < response.getPageSize()) { + if (response.getTotalItems() <= response.getPageSize()) { return responseSessions; } else if (responseSessions == null) { diff --git a/src/test/java/com/vonage/client/meetings/MeetingsClientTest.java b/src/test/java/com/vonage/client/meetings/MeetingsClientTest.java index e715a9514..a752c70f8 100644 --- a/src/test/java/com/vonage/client/meetings/MeetingsClientTest.java +++ b/src/test/java/com/vonage/client/meetings/MeetingsClientTest.java @@ -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 sessions = client.listAllSessions(); @@ -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