@ -63,13 +63,18 @@ public class PageableEncoderTests {
@@ -63,13 +63,18 @@ public class PageableEncoderTests {
encoder . encode ( createPageAndSortRequest ( ) , null , request ) ;
// Request queries shall contain three entries
assertThat ( request . queries ( ) . size ( ) ) . isEqualTo ( 3 ) ;
assertThat ( request . queries ( ) ) . hasSize ( 3 ) ;
// Request page shall contain page
assertThat ( request . queries ( ) . get ( "page" ) ) . contains ( String . valueOf ( PAGE ) ) ;
// Request size shall contain size
assertThat ( request . queries ( ) . get ( "size" ) ) . contains ( String . valueOf ( SIZE ) ) ;
// Request sort size shall contain sort entries
assertThat ( request . queries ( ) . get ( "sort" ) . size ( ) ) . isEqualTo ( 2 ) ;
assertThat ( request . queries ( ) . get ( "size" ) ) . contains ( String . valueOf ( SIZE ) ) ; // Request
// sort
// size
// shall
// contain
// sort
// entries
assertThat ( request . queries ( ) . get ( "sort" ) ) . hasSize ( 2 ) ;
}
private Pageable createPageAndSortRequest ( ) {
@ -86,9 +91,14 @@ public class PageableEncoderTests {
@@ -86,9 +91,14 @@ public class PageableEncoderTests {
// Request page shall contain page
assertThat ( request . queries ( ) . get ( "page" ) ) . contains ( String . valueOf ( PAGE ) ) ;
// Request size shall contain size
assertThat ( request . queries ( ) . get ( "size" ) ) . contains ( String . valueOf ( SIZE ) ) ;
// Request sort size shall contain sort entries
assertThat ( request . queries ( ) . containsKey ( "sort" ) ) . isEqualTo ( false ) ;
assertThat ( request . queries ( ) . get ( "size" ) ) . contains ( String . valueOf ( SIZE ) ) ; // Request
// sort
// size
// shall
// contain
// sort
// entries
assertThat ( request . queries ( ) ) . doesNotContainKey ( "sort" ) ;
}
private Pageable createPageAndRequest ( ) {
@ -105,11 +115,22 @@ public class PageableEncoderTests {
@@ -105,11 +115,22 @@ public class PageableEncoderTests {
// Request queries shall contain three entries
assertThat ( request . queries ( ) . size ( ) ) . isEqualTo ( 1 ) ;
// Request sort size shall contain sort entries
assertThat ( request . queries ( ) . get ( "sort" ) . size ( ) ) . isEqualTo ( 2 ) ;
assertThat ( request . queries ( ) . get ( "sort" ) ) . hasSize ( 2 ) ;
}
private Sort createSort ( ) {
return Sort . by ( SORT_1 , SORT_2 ) . ascending ( ) ;
}
@Test
public void testUnpagedRequest ( ) {
Encoder encoder = this . context . getInstance ( "foo" , Encoder . class ) ;
assertThat ( encoder ) . isNotNull ( ) ;
RequestTemplate request = new RequestTemplate ( ) ;
encoder . encode ( Pageable . unpaged ( ) , null , request ) ;
// Request queries shall contain three entries
assertThat ( request . queries ( ) ) . isEmpty ( ) ;
}
}