@@ -3169,6 +3169,79 @@ public void epersonMemberPaginationTest() throws Exception {
31693169 .andExpect (jsonPath ("$.page.totalElements" , is (5 )));
31703170 }
31713171
3172+ // Test of /groups/[uuid]/subgroups pagination
3173+ @ Test
3174+ public void subgroupPaginationTest () throws Exception {
3175+ context .turnOffAuthorisationSystem ();
3176+
3177+ Group group = GroupBuilder .createGroup (context )
3178+ .withName ("Test group" )
3179+ .build ();
3180+
3181+ GroupBuilder .createGroup (context )
3182+ .withParent (group )
3183+ .withName ("Test subgroup 1" )
3184+ .build ();
3185+ GroupBuilder .createGroup (context )
3186+ .withParent (group )
3187+ .withName ("Test subgroup 2" )
3188+ .build ();
3189+ GroupBuilder .createGroup (context )
3190+ .withParent (group )
3191+ .withName ("Test subgroup 3" )
3192+ .build ();
3193+ GroupBuilder .createGroup (context )
3194+ .withParent (group )
3195+ .withName ("Test subgroup 4" )
3196+ .build ();
3197+ GroupBuilder .createGroup (context )
3198+ .withParent (group )
3199+ .withName ("Test subgroup 5" )
3200+ .build ();
3201+
3202+ context .restoreAuthSystemState ();
3203+
3204+ String authTokenAdmin = getAuthToken (admin .getEmail (), password );
3205+ getClient (authTokenAdmin ).perform (get ("/api/eperson/groups/" + group .getID () + "/subgroups" )
3206+ .param ("page" , "0" )
3207+ .param ("size" , "2" ))
3208+ .andExpect (status ().isOk ()).andExpect (content ().contentType (contentType ))
3209+ .andExpect (jsonPath ("$._embedded.subgroups" , Matchers .everyItem (
3210+ hasJsonPath ("$.type" , is ("group" )))
3211+ ))
3212+ .andExpect (jsonPath ("$._embedded.subgroups" ).value (Matchers .hasSize (2 )))
3213+ .andExpect (jsonPath ("$.page.size" , is (2 )))
3214+ .andExpect (jsonPath ("$.page.number" , is (0 )))
3215+ .andExpect (jsonPath ("$.page.totalPages" , is (3 )))
3216+ .andExpect (jsonPath ("$.page.totalElements" , is (5 )));
3217+
3218+ getClient (authTokenAdmin ).perform (get ("/api/eperson/groups/" + group .getID () + "/subgroups" )
3219+ .param ("page" , "1" )
3220+ .param ("size" , "2" ))
3221+ .andExpect (status ().isOk ()).andExpect (content ().contentType (contentType ))
3222+ .andExpect (jsonPath ("$._embedded.subgroups" , Matchers .everyItem (
3223+ hasJsonPath ("$.type" , is ("group" )))
3224+ ))
3225+ .andExpect (jsonPath ("$._embedded.subgroups" ).value (Matchers .hasSize (2 )))
3226+ .andExpect (jsonPath ("$.page.size" , is (2 )))
3227+ .andExpect (jsonPath ("$.page.number" , is (1 )))
3228+ .andExpect (jsonPath ("$.page.totalPages" , is (3 )))
3229+ .andExpect (jsonPath ("$.page.totalElements" , is (5 )));
3230+
3231+ getClient (authTokenAdmin ).perform (get ("/api/eperson/groups/" + group .getID () + "/subgroups" )
3232+ .param ("page" , "2" )
3233+ .param ("size" , "2" ))
3234+ .andExpect (status ().isOk ()).andExpect (content ().contentType (contentType ))
3235+ .andExpect (jsonPath ("$._embedded.subgroups" , Matchers .everyItem (
3236+ hasJsonPath ("$.type" , is ("group" )))
3237+ ))
3238+ .andExpect (jsonPath ("$._embedded.subgroups" ).value (Matchers .hasSize (1 )))
3239+ .andExpect (jsonPath ("$.page.size" , is (2 )))
3240+ .andExpect (jsonPath ("$.page.number" , is (2 )))
3241+ .andExpect (jsonPath ("$.page.totalPages" , is (3 )))
3242+ .andExpect (jsonPath ("$.page.totalElements" , is (5 )));
3243+ }
3244+
31723245 @ Test
31733246 public void commAdminAndColAdminCannotExploitItemReadGroupTest () throws Exception {
31743247
0 commit comments