use of de.geeksfactory.opacclient.apis.OpacApi.OpacErrorException in project opacclient by opacapp.
the class LibraryApiTestCases method scrollTestHelper.
public void scrollTestHelper(String q) throws OpacErrorException, IOException, JSONException {
List<SearchQuery> query = new ArrayList<>();
SearchField field = findFreeSearchOrTitle(fields);
if (field == null) {
throw new // TODO: prevent this
OpacErrorException("There is no free or title search field");
}
query.add(new SearchQuery(field, q));
SearchRequestResult res = api.search(query);
assertTrue(res.getTotal_result_count() == -1 || res.getResults().size() <= res.getTotal_result_count());
assertTrue(res.getResults().size() > 0);
SearchResult third;
if (res.getResults().size() >= 3) {
third = res.getResults().get(2);
} else {
third = res.getResults().get(res.getResults().size() - 1);
}
DetailedItem detail;
if (third.getId() != null) {
detail = api.getResultById(third.getId(), "");
} else {
detail = api.getResult(third.getNr());
}
assertNotNull(detail);
confirmDetail(third, detail);
if (res.getResults().size() < res.getTotal_result_count()) {
api.searchGetPage(2);
SearchResult second = res.getResults().get(1);
DetailedItem detail2;
if (second.getId() != null) {
detail2 = api.getResultById(second.getId(), "");
} else {
detail2 = api.getResult(second.getNr());
}
confirmDetail(second, detail2);
}
}
Aggregations