Search in sources :

Example 6 with OpacErrorException

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);
    }
}
Also used : SearchQuery(de.geeksfactory.opacclient.searchfields.SearchQuery) TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField) SearchField(de.geeksfactory.opacclient.searchfields.SearchField) SearchRequestResult(de.geeksfactory.opacclient.objects.SearchRequestResult) ArrayList(java.util.ArrayList) OpacErrorException(de.geeksfactory.opacclient.apis.OpacApi.OpacErrorException) SearchResult(de.geeksfactory.opacclient.objects.SearchResult) DetailedItem(de.geeksfactory.opacclient.objects.DetailedItem)

Aggregations

OpacErrorException (de.geeksfactory.opacclient.apis.OpacApi.OpacErrorException)6 SearchRequestResult (de.geeksfactory.opacclient.objects.SearchRequestResult)3 OpacClient (de.geeksfactory.opacclient.OpacClient)2 OpacApi (de.geeksfactory.opacclient.apis.OpacApi)2 NotReachableException (de.geeksfactory.opacclient.networking.NotReachableException)2 SSLSecurityException (de.geeksfactory.opacclient.networking.SSLSecurityException)2 SearchResult (de.geeksfactory.opacclient.objects.SearchResult)2 SearchField (de.geeksfactory.opacclient.searchfields.SearchField)2 SearchQuery (de.geeksfactory.opacclient.searchfields.SearchQuery)2 TextSearchField (de.geeksfactory.opacclient.searchfields.TextSearchField)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JSONException (org.json.JSONException)2 Test (org.junit.Test)2 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 Button (android.widget.Button)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1