@@ -2663,9 +2663,31 @@ private ResultActions performDeleteResource(String accessToken, String type, Str
26632663 delete (path )
26642664 .header ("Authorization" , "Bearer " + accessToken ));
26652665 }
2666-
2666+
2667+ @ Test
2668+ void testGetAllPaginatedContents () throws Exception {
2669+ UserDetails user = new OAuth2TestUtils .UserBuilder ("jack_bauer" , "0x24" ).grantedToRoleAdmin ().build ();
2670+ String accessToken = mockOAuthInterceptor (user );
2671+ this .executeTestGetAllPaginatedContents (accessToken , IContentService .STATUS_DRAFT , 25 );
2672+ this .executeTestGetAllPaginatedContents (accessToken , IContentService .STATUS_ONLINE , 24 );
2673+ }
2674+
2675+ void executeTestGetAllPaginatedContents (String accessToken , String status , int expected ) throws Exception {
2676+ ResultActions result = mockMvc
2677+ .perform (get ("/plugins/cms/contents?page=1&pageSize=100" )
2678+ .param ("sort" , IContentManager .CONTENT_CREATION_DATE_FILTER_KEY )
2679+ .param ("direction" , FieldSearchFilter .DESC_ORDER )
2680+ .param ("status" , status )
2681+ .header ("Authorization" , "Bearer " + accessToken ));
2682+ String bodyResult = result .andReturn ().getResponse ().getContentAsString ();
2683+ Integer payloadSize = JsonPath .read (bodyResult , "$.payload.size()" );
2684+ Assertions .assertEquals (expected , payloadSize .intValue ());
2685+ result .andExpect (status ().isOk ());
2686+ result .andExpect (jsonPath ("$.metaData.totalItems" , is (payloadSize )));
2687+ }
2688+
26672689 @ Test
2668- void testGetContentsPaginated () throws Exception {
2690+ void testGetEvnContentsPaginated () throws Exception {
26692691 UserDetails user = new OAuth2TestUtils .UserBuilder ("jack_bauer" , "0x24" ).grantedToRoleAdmin ().build ();
26702692 String accessToken = mockOAuthInterceptor (user );
26712693 ResultActions result = mockMvc
@@ -2676,9 +2698,7 @@ void testGetContentsPaginated() throws Exception {
26762698 .param ("filter[0].operator" , "eq" )
26772699 .param ("filter[0].value" , "EVN" )
26782700 .header ("Authorization" , "Bearer " + accessToken ));
2679- result
2680- .andDo (resultPrint ())
2681- .andExpect (status ().isOk ())
2701+ result .andExpect (status ().isOk ())
26822702 .andExpect (jsonPath ("$.payload.size()" , is (2 )))
26832703 .andExpect (jsonPath ("$.metaData.page" , is (1 )))
26842704 .andExpect (jsonPath ("$.metaData.pageSize" , is (2 )))
0 commit comments