WebOpacNet extends OkHttpBaseApi implements OpacApi { static String[] getTitleAndSubtitle(String title) { Matcher titleMatcher = Pattern.compile("<\u00ac1>([^<]*)</\u00ac1>").matcher(title); Matcher subtitleMatcher = Pattern.compile("<\u00ac2>([^<]*)</\u00ac2>").matcher(title); if (titleMatcher.find()) { String theTitle = Jsoup.parse(titleMatcher.group(1)).text(); if (subtitleMatcher.find()) { String subtitle = Jsoup.parse(subtitleMatcher.group(1)).text(); return new String[]{theTitle, subtitle}; } else { return new String[]{theTitle}; } } else { return new String[]{title}; } }  @Override void init(Library lib, HttpClientFactory httpClientFactory); @Override void start(); @Override SearchRequestResult search(List<SearchQuery> query); @Override SearchRequestResult filterResults(Filter filter, Option option); @Override SearchRequestResult searchGetPage(int page); @Override DetailedItem getResultById(String id, String homebranch); @Override DetailedItem getResult(int position); @Override ReservationResult reservation(DetailedItem item, Account account,
            int useraction, String selection); @Override ProlongResult prolong(String media, Account account, int useraction,
            String selection); @Override ProlongAllResult prolongAll(Account account, int useraction,
            String selection); @Override CancelResult cancel(String media, Account account, int useraction,
            String selection); @Override AccountData account(Account account); @Override List<SearchField> parseSearchFields(); @Override String getShareUrl(String id, String title); @Override int getSupportFlags(); @Override void checkAccountData(Account account); @Override void setLanguage(String language); @Override Set<String> getSupportedLanguages();  }
@Test public void testSetTitleAndSubtitleSimple() { String[] titleAndSubtitle = WebOpacNet.getTitleAndSubtitle("A Title"); assertEquals("A Title", titleAndSubtitle[0]); assertEquals(1, titleAndSubtitle.length); }
@Test public void testSetTitleAndSubtitleTitle() { String[] titleAndSubtitle = WebOpacNet .getTitleAndSubtitle("<¬1>K&#246;rper und Seele [DVD-Videoaufzeichnung]</¬1>"); assertEquals("Körper und Seele [DVD-Videoaufzeichnung]", titleAndSubtitle[0]); assertEquals(1, titleAndSubtitle.length); }
@Test public void testSetTitleAndSubtitleBoth() { String[] titleAndSubtitle = WebOpacNet.getTitleAndSubtitle( "<¬1>Letzte Dinge regeln</¬1><¬2>f&#252;rs Lebensende vorsorgen - mit " + "Todesf&#228;llen umgehen</¬2>"); assertEquals("Letzte Dinge regeln", titleAndSubtitle[0]); assertEquals("fürs Lebensende vorsorgen - mit Todesfällen umgehen", titleAndSubtitle[1]); }