@@ -2663,9 +2663,31 @@ private ResultActions performDeleteResource(String accessToken, String type, Str
2663
2663
delete (path )
2664
2664
.header ("Authorization" , "Bearer " + accessToken ));
2665
2665
}
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
+
2667
2689
@ Test
2668
- void testGetContentsPaginated () throws Exception {
2690
+ void testGetEvnContentsPaginated () throws Exception {
2669
2691
UserDetails user = new OAuth2TestUtils .UserBuilder ("jack_bauer" , "0x24" ).grantedToRoleAdmin ().build ();
2670
2692
String accessToken = mockOAuthInterceptor (user );
2671
2693
ResultActions result = mockMvc
@@ -2676,9 +2698,7 @@ void testGetContentsPaginated() throws Exception {
2676
2698
.param ("filter[0].operator" , "eq" )
2677
2699
.param ("filter[0].value" , "EVN" )
2678
2700
.header ("Authorization" , "Bearer " + accessToken ));
2679
- result
2680
- .andDo (resultPrint ())
2681
- .andExpect (status ().isOk ())
2701
+ result .andExpect (status ().isOk ())
2682
2702
.andExpect (jsonPath ("$.payload.size()" , is (2 )))
2683
2703
.andExpect (jsonPath ("$.metaData.page" , is (1 )))
2684
2704
.andExpect (jsonPath ("$.metaData.pageSize" , is (2 )))
0 commit comments