Additional pagination tests

This commit is contained in:
Raf Ponsaerts
2019-05-07 09:19:48 +02:00
parent 6e21bcdad1
commit aac6b12de9
2 changed files with 29 additions and 1 deletions

View File

@@ -55,7 +55,6 @@ public class EntityTypeRestRepositoryIT extends AbstractEntityIntegrationTest {
@Test
public void getAllEntityTypeEndpointWithPaging() throws Exception {
//When we call this facets endpoint
getClient().perform(get("/api/core/entitytypes").param("size", "5"))
//We expect a 200 OK status
@@ -75,6 +74,25 @@ public class EntityTypeRestRepositoryIT extends AbstractEntityIntegrationTest {
EntityTypeMatcher.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "OrgUnit")),
EntityTypeMatcher.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "Journal"))
)));
getClient().perform(get("/api/core/entitytypes").param("size", "5").param("page", "1"))
//We expect a 200 OK status
.andExpect(status().isOk())
//The type has to be 'discover'
.andExpect(jsonPath("$.page.size", is(5)))
.andExpect(jsonPath("$.page.totalElements", is(7)))
.andExpect(jsonPath("$.page.totalPages", is(2)))
.andExpect(jsonPath("$.page.number", is(1)))
//There needs to be a self link to this endpoint
.andExpect(jsonPath("$._links.self.href", containsString("api/core/entitytypes")))
//We have 4 facets in the default configuration, they need to all be present in the embedded section
.andExpect(jsonPath("$._embedded.entitytypes", containsInAnyOrder(
EntityTypeMatcher
.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "JournalVolume")),
EntityTypeMatcher
.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "JournalIssue"))
)));
}
@Test

View File

@@ -7,6 +7,7 @@
*/
package org.dspace.app.rest;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
@@ -173,6 +174,15 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
)))
;
getClient().perform(get("/api/core/relationships").param("size", "2").param("page", "1"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.page",
is(PageMatcher.pageEntryWithTotalPagesAndElements(1, 2, 2, 3))))
.andExpect(jsonPath("$._embedded.relationships", contains(
RelationshipMatcher.matchRelationship(relationship3)
)))
;
}