package de.geeksfactory.opacclient.apis;

import org.json.JSONObject;
import org.junit.Test;

import java.util.Collections;
import java.util.Objects;

import de.geeksfactory.opacclient.objects.Library;
import de.geeksfactory.opacclient.searchfields.SearchQuery;

public class WebOpacAtTest {

    WebOpacAt getApi() {
        WebOpacAt api = new WebOpacAt();
        Library lib = new Library();
        lib.setData(new JSONObject(Collections.singletonMap("baseurl", "http://www.stbinnsbruck.web-opac.at")));
        api.init(lib);
        return api;
    }

    @Test
    public void testParseTotalResults() {
        assert WebOpacAt.parseTotalResults("Treffer pro Seite  •  1 - 10 von 46 Treffern") == 46;
        assert WebOpacAt.parseTotalResults("Hits per page  •  1 - 10 of 46") == 46;
        assert WebOpacAt.parseTotalResults("Sayfa başına sonuç  •  46 sonuçtan 1 - 10") == 46;
    }

    @Test
    public void testParseCopyReturn() throws Exception {
        assert Objects.equals(WebOpacAt.parseCopyReturn("1 (voraussichtl. bis 31.07.2015)"), "31.07.2015");

    }

    @Test
    public void testSearchFields() throws Exception {
        getApi().getSearchFields();
    }

    @Test
    public void testEmptyQuery() throws Exception {
        getApi().search(Collections.<SearchQuery>emptyList());
    }

}

@@ -39,36 +39,8 @@
 s;%0A%0A
-import org.json.JSONObject;%0A
 impo
@@ -80,454 +80,46 @@
 til.
-Collections;%0Aimport java.util.Objects;%0A%0Aimport de.geeksfactory.opacclient.objects.Library;%0Aimport de.geeksfactory.opacclient.searchfields.SearchQuery;%0A%0Apublic class WebOpacAtTest %7B%0A%0A    WebOpacAt getApi() %7B%0A        WebOpacAt api = new WebOpacAt();%0A        Library lib = new Library();%0A        lib.setData(new JSONObject(Collections.singletonMap(%22baseurl%22, %22http://www.stbinnsbruck.web-opac.at%22)));%0A        api.init(lib);%0A        return api;%0A    %7D
+Objects;%0A%0Apublic class WebOpacAtTest %7B
 %0A%0A  
@@ -639,245 +639,6 @@
  %7D%0A%0A
-    @Test%0A    public void testSearchFields() throws Exception %7B%0A        getApi().getSearchFields();%0A    %7D%0A%0A    @Test%0A    public void testEmptyQuery() throws Exception %7B%0A        getApi().search(Collections.%3CSearchQuery%3EemptyList());%0A    %7D%0A%0A
 %7D%0A

remove calls to online API