UntisCommonParser extends BaseParser { static void handleRoom(Substitution subst, Element cell, boolean previousRoom) { cell = getContentElement(cell); if (cell.select("s").size() > 0) { subst.setPreviousRoom(cell.select("s").text()); if (cell.ownText().length() > 0) { subst.setRoom(cell.ownText().replaceFirst("^\\?", "").replaceFirst("→", "")); } } else { if (previousRoom) { subst.setPreviousRoom(cell.text()); } else { subst.setRoom(cell.text()); } } } UntisCommonParser(SubstitutionScheduleData scheduleData, CookieProvider cookieProvider); @Override List<String> getAllClasses();  }
@Test public void testHandleRoomSingle() throws Exception { Substitution subst = new Substitution(); Element cell = Jsoup.parse("<table><td>224</td></table>") .select("td").first(); UntisCommonParser.handleRoom(subst, cell, false); assertEquals(null, subst.getPreviousRoom()); assertEquals("224", subst.getRoom()); }
@Test public void testHandleRoomSinglePrevious() throws Exception { Substitution subst = new Substitution(); Element cell = Jsoup.parse("<table><td><s>264</s></td></table>") .select("td").first(); UntisCommonParser.handleRoom(subst, cell, false); assertEquals("264", subst.getPreviousRoom()); assertEquals(null, subst.getRoom()); }
@Test public void testHandleRoomBoth() throws Exception { Substitution subst = new Substitution(); Element cell = Jsoup.parse("<table><td><s>248</s>?236</td></table>") .select("td").first(); UntisCommonParser.handleRoom(subst, cell, false); assertEquals("248", subst.getPreviousRoom()); assertEquals("236", subst.getRoom()); }
@Test public void testHandleRoomBothSpan() throws Exception { Substitution subst = new Substitution(); Element cell = Jsoup.parse("<table><td><span style=\"color: #010101\"><s>248</s>?236</span></td></table>") .select("td").first(); UntisCommonParser.handleRoom(subst, cell, false); assertEquals("248", subst.getPreviousRoom()); assertEquals("236", subst.getRoom()); }