Search in sources :

Example 6 with DummyStringProvider

use of de.geeksfactory.opacclient.i18n.DummyStringProvider in project opacclient by opacapp.

the class PicaOldAccountTest method testParseMediaList.

@Test
public void testParseMediaList() throws OpacApi.OpacErrorException {
    String html = readResource("/pica_old/medialist/" + file);
    // we may not have all files for all libraries
    if (html == null)
        return;
    List<LentItem> media = new ArrayList<>();
    PicaOld.parseMediaList(media, Jsoup.parse(html), new DummyStringProvider(), new ArrayList<String>());
    assertTrue(media.size() > 0);
    for (LentItem item : media) {
        assertNotNull(item.getTitle());
        assertNotNull(item.getDeadline());
    }
}
Also used : DummyStringProvider(de.geeksfactory.opacclient.i18n.DummyStringProvider) ArrayList(java.util.ArrayList) LentItem(de.geeksfactory.opacclient.objects.LentItem) Test(org.junit.Test)

Example 7 with DummyStringProvider

use of de.geeksfactory.opacclient.i18n.DummyStringProvider in project opacclient by opacapp.

the class SISISSearchTest method testParseDetail.

@Test
public void testParseDetail() throws OpacApi.OpacErrorException, JSONException, IOException {
    String html1 = readResource("/sisis/result_detail/" + file.replace(".html", "_1.html"));
    String html2 = readResource("/sisis/result_detail/" + file.replace(".html", "_2.html"));
    String html3 = readResource("/sisis/result_detail/" + file.replace(".html", "_3.html"));
    String coverJs = readResource("/sisis/result_detail/" + file.replace(".html", ".js"));
    if (html1 == null || html2 == null || html3 == null) {
        // we may not have all files for all libraries
        return;
    }
    DetailedItem result = SISIS.parseDetail(html1, html2, html3, coverJs, new JSONObject(), new DummyStringProvider());
    assertTrue(result.getCopies().size() > 0);
    for (Copy copy : result.getCopies()) {
        assertContainsData(copy.getStatus());
        assertNullOrNotEmpty(copy.getBarcode());
        assertNullOrNotEmpty(copy.getBranch());
        assertNullOrNotEmpty(copy.getDepartment());
        assertNullOrNotEmpty(copy.getLocation());
        assertNullOrNotEmpty(copy.getReservations());
        assertNullOrNotEmpty(copy.getShelfmark());
        assertNullOrNotEmpty(copy.getUrl());
        if (copy.getStatus().equals("Entliehen"))
            assertNotNull(copy.getReturnDate());
    }
    for (Volume volume : result.getVolumes()) {
        assertContainsData(volume.getId());
        assertContainsData(volume.getTitle());
    }
    assertEquals(result.getTitle(), getDetailTitle(file));
    if (file.equals("berlin_htw.html")) {
        assertTrue(result.getDetails().contains(new Detail("Signatur:", "15/2322")));
        assertNotNull(result.getCover());
    }
}
Also used : DummyStringProvider(de.geeksfactory.opacclient.i18n.DummyStringProvider) JSONObject(org.json.JSONObject) Copy(de.geeksfactory.opacclient.objects.Copy) Volume(de.geeksfactory.opacclient.objects.Volume) DetailedItem(de.geeksfactory.opacclient.objects.DetailedItem) Detail(de.geeksfactory.opacclient.objects.Detail) Test(org.junit.Test)

Example 8 with DummyStringProvider

use of de.geeksfactory.opacclient.i18n.DummyStringProvider in project opacclient by opacapp.

the class ApacheBaseApi method init.

/**
 * Initializes HTTP client and String Provider
 */
@Override
public void init(Library library, HttpClientFactory http_client_factory) {
    http_client = http_client_factory.getNewApacheHttpClient(library.getData().optBoolean("customssl", false), library.getData().optBoolean("customssl_tls_only", true), library.getData().optBoolean("customssl_all_ciphersuites", false), library.getData().optBoolean("disguise", false));
    this.library = library;
    stringProvider = new DummyStringProvider();
}
Also used : DummyStringProvider(de.geeksfactory.opacclient.i18n.DummyStringProvider)

Example 9 with DummyStringProvider

use of de.geeksfactory.opacclient.i18n.DummyStringProvider in project opacclient by opacapp.

the class BaseApi method init.

/**
 * Initializes HTTP client and String Provider
 */
@Override
public void init(Library library, HttpClientFactory http_client_factory) {
    this.library = library;
    stringProvider = new DummyStringProvider();
}
Also used : DummyStringProvider(de.geeksfactory.opacclient.i18n.DummyStringProvider)

Example 10 with DummyStringProvider

use of de.geeksfactory.opacclient.i18n.DummyStringProvider in project opacclient by opacapp.

the class OkHttpBaseApi method init.

/**
 * Initializes HTTP client and String Provider
 */
@Override
public void init(Library library, HttpClientFactory http_client_factory) {
    this.http_client_factory = http_client_factory;
    http_client = http_client_factory.getNewOkHttpClient(library.getData().optBoolean("customssl", false), library.getData().optBoolean("customssl_tls_only", true), library.getData().optBoolean("customssl_all_ciphersuites", false));
    http_client.dispatcher().setMaxRequestsPerHost(10);
    this.library = library;
    stringProvider = new DummyStringProvider();
}
Also used : DummyStringProvider(de.geeksfactory.opacclient.i18n.DummyStringProvider)

Aggregations

DummyStringProvider (de.geeksfactory.opacclient.i18n.DummyStringProvider)10 Test (org.junit.Test)7 ReservedItem (de.geeksfactory.opacclient.objects.ReservedItem)4 ArrayList (java.util.ArrayList)3 LentItem (de.geeksfactory.opacclient.objects.LentItem)2 JSONObject (org.json.JSONObject)2 Copy (de.geeksfactory.opacclient.objects.Copy)1 Detail (de.geeksfactory.opacclient.objects.Detail)1 DetailedItem (de.geeksfactory.opacclient.objects.DetailedItem)1 Volume (de.geeksfactory.opacclient.objects.Volume)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1