Skip to content

Commit

Permalink
Merge pull request #1437 from UNC-Libraries/BXC-3733-search-json-paging
Browse files Browse the repository at this point in the history
BXC-3733 added two tests for start index and page size
  • Loading branch information
bbpennel authored Jul 21, 2022
2 parents 436af49 + ecf78dc commit f47c41a
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,40 @@ public void testSearchWithReversedSorting() throws Exception {
assertValuePresent(metadata, 0, "title", "Work Object");
}
}

@Test
public void testSearchWithALowerPageSize() throws Exception {
createDefaultObjects();
collectionFactory.createCollection(adminUnit1,
Map.of("title", "A first collection", "readGroup", "everyone"));
folderFactory.createFolder(collection,
Map.of("title", "Folder Object 2", "readGroup", "everyone"));

var getMethod = new HttpGet(SEARCH_URL + "/?start=0&rows=5");

try (var resp = httpClient.execute(getMethod)) {
var metadata = getMetadataFromResponse(resp);

assertSuccessfulResponse(resp);
// there are seven objects but this search should only return 5 because of page size
assertEquals(5, metadata.size());
}
}

@Test
public void testSearchWithADifferentStartIndex() throws Exception {
createDefaultObjects();
collectionFactory.createCollection(adminUnit1,
Map.of("title", "A first collection", "readGroup", "everyone"));

var getMethod = new HttpGet(SEARCH_URL + "/?start=3");

try (var resp = httpClient.execute(getMethod)) {
var metadata = getMetadataFromResponse(resp);

assertSuccessfulResponse(resp);
// there are 6 total items, but since the index starts at 3 we should have only 3 results
assertEquals(3, metadata.size());
}
}
}

0 comments on commit f47c41a

Please sign in to comment.