|
|
@ -63,13 +63,18 @@ public class PageableEncoderTests { |
|
|
|
encoder.encode(createPageAndSortRequest(), null, request); |
|
|
|
encoder.encode(createPageAndSortRequest(), null, request); |
|
|
|
|
|
|
|
|
|
|
|
// Request queries shall contain three entries
|
|
|
|
// Request queries shall contain three entries
|
|
|
|
assertThat(request.queries().size()).isEqualTo(3); |
|
|
|
assertThat(request.queries()).hasSize(3); |
|
|
|
// Request page shall contain page
|
|
|
|
// Request page shall contain page
|
|
|
|
assertThat(request.queries().get("page")).contains(String.valueOf(PAGE)); |
|
|
|
assertThat(request.queries().get("page")).contains(String.valueOf(PAGE)); |
|
|
|
// Request size shall contain size
|
|
|
|
// Request size shall contain size
|
|
|
|
assertThat(request.queries().get("size")).contains(String.valueOf(SIZE)); |
|
|
|
assertThat(request.queries().get("size")).contains(String.valueOf(SIZE)); // Request
|
|
|
|
// Request sort size shall contain sort entries
|
|
|
|
// sort
|
|
|
|
assertThat(request.queries().get("sort").size()).isEqualTo(2); |
|
|
|
// size
|
|
|
|
|
|
|
|
// shall
|
|
|
|
|
|
|
|
// contain
|
|
|
|
|
|
|
|
// sort
|
|
|
|
|
|
|
|
// entries
|
|
|
|
|
|
|
|
assertThat(request.queries().get("sort")).hasSize(2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Pageable createPageAndSortRequest() { |
|
|
|
private Pageable createPageAndSortRequest() { |
|
|
@ -86,9 +91,14 @@ public class PageableEncoderTests { |
|
|
|
// Request page shall contain page
|
|
|
|
// Request page shall contain page
|
|
|
|
assertThat(request.queries().get("page")).contains(String.valueOf(PAGE)); |
|
|
|
assertThat(request.queries().get("page")).contains(String.valueOf(PAGE)); |
|
|
|
// Request size shall contain size
|
|
|
|
// Request size shall contain size
|
|
|
|
assertThat(request.queries().get("size")).contains(String.valueOf(SIZE)); |
|
|
|
assertThat(request.queries().get("size")).contains(String.valueOf(SIZE)); // Request
|
|
|
|
// Request sort size shall contain sort entries
|
|
|
|
// sort
|
|
|
|
assertThat(request.queries().containsKey("sort")).isEqualTo(false); |
|
|
|
// size
|
|
|
|
|
|
|
|
// shall
|
|
|
|
|
|
|
|
// contain
|
|
|
|
|
|
|
|
// sort
|
|
|
|
|
|
|
|
// entries
|
|
|
|
|
|
|
|
assertThat(request.queries()).doesNotContainKey("sort"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Pageable createPageAndRequest() { |
|
|
|
private Pageable createPageAndRequest() { |
|
|
@ -105,11 +115,22 @@ public class PageableEncoderTests { |
|
|
|
// Request queries shall contain three entries
|
|
|
|
// Request queries shall contain three entries
|
|
|
|
assertThat(request.queries().size()).isEqualTo(1); |
|
|
|
assertThat(request.queries().size()).isEqualTo(1); |
|
|
|
// Request sort size shall contain sort entries
|
|
|
|
// 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() { |
|
|
|
private Sort createSort() { |
|
|
|
return Sort.by(SORT_1, SORT_2).ascending(); |
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|