UntisMonitorParser extends UntisCommonParser { static void findSubDocs(List<Document> docs, String html, Document doc) { Pattern pattern = Pattern.compile("(<html>.*?</html>)", Pattern.DOTALL); Matcher matcher = pattern.matcher(html); List<String> subHtmls = new ArrayList<>(); while (matcher.find()) { subHtmls.add(matcher.group()); } if (subHtmls.size() > 1) { for (String subHtml : subHtmls) { docs.add(Jsoup.parse(subHtml)); } } else { docs.add(doc); } } UntisMonitorParser(SubstitutionScheduleData scheduleData, CookieProvider cookieProvider); SubstitutionSchedule getSubstitutionSchedule(); List<String> getAllTeachers();  }
@Test public void testFindSubDocsSingle() { String html = "<html>blabla</html>"; Document doc = Jsoup.parse(html); List<Document> docs = new ArrayList<>(); UntisMonitorParser.findSubDocs(docs, html, doc); assertEquals(docs.size(), 1); assertEquals(docs.get(0), doc); }
@Test public void testFindSubDocsMultiple() { String html = "<html>1</html><html>2</html>"; Document doc = Jsoup.parse(html); List<Document> docs = new ArrayList<>(); UntisMonitorParser.findSubDocs(docs, html, doc); assertEquals(docs.size(), 2); assertEquals(docs.get(0).text(), "1"); assertEquals(docs.get(1).text(), "2"); }