@Test public void testFindMenuItemsNormalMenu() { String filename = "/middag/normalMenuHangaren.html"; String html = readResourceFile(filename); assertEquals( "Champignonsuppe (V,G,L) 20,- Røkt torsk med gulrotstuin... 63,- Svinesteik med surkål, gul... 68,- Vegetarlasagne (V) 62,-", UpdateMenu.findMenuItems(html) ); filename = "/middag/normalMenuRealfag.html"; html = readResourceFile(filename); assertEquals( "Fiskeburger med stekte pote... 62,- Karbonade i pitabrød med s... 48,- Falaffel med couscouspytt (... 62,- Bønnesuppe med kjøtt (G,L) 20,-", UpdateMenu.findMenuItems(html) ); }
protected static String findMenuItems(String html) { Document doc = Jsoup.parse(html); String menu = ""; Element ul = doc.select("ul").first(); if (ul != null) { for (Element li : ul.children()) { menu += li.select(".food").text() + " " + li.select(".price").text() + " "; } return menu.trim(); } Element p = doc.select("p").first(); if (p != null) { return p.text(); } logger.debug("Unmatched dinner menu: " + html); return "No matches for menu items were found."; }
UpdateMenu implements Runnable { protected static String findMenuItems(String html) { Document doc = Jsoup.parse(html); String menu = ""; Element ul = doc.select("ul").first(); if (ul != null) { for (Element li : ul.children()) { menu += li.select(".food").text() + " " + li.select(".price").text() + " "; } return menu.trim(); } Element p = doc.select("p").first(); if (p != null) { return p.text(); } logger.debug("Unmatched dinner menu: " + html); return "No matches for menu items were found."; } }
UpdateMenu implements Runnable { protected static String findMenuItems(String html) { Document doc = Jsoup.parse(html); String menu = ""; Element ul = doc.select("ul").first(); if (ul != null) { for (Element li : ul.children()) { menu += li.select(".food").text() + " " + li.select(".price").text() + " "; } return menu.trim(); } Element p = doc.select("p").first(); if (p != null) { return p.text(); } logger.debug("Unmatched dinner menu: " + html); return "No matches for menu items were found."; } UpdateMenu(MiddagPlugin middagPlugin, String kantine); }
UpdateMenu implements Runnable { protected static String findMenuItems(String html) { Document doc = Jsoup.parse(html); String menu = ""; Element ul = doc.select("ul").first(); if (ul != null) { for (Element li : ul.children()) { menu += li.select(".food").text() + " " + li.select(".price").text() + " "; } return menu.trim(); } Element p = doc.select("p").first(); if (p != null) { return p.text(); } logger.debug("Unmatched dinner menu: " + html); return "No matches for menu items were found."; } UpdateMenu(MiddagPlugin middagPlugin, String kantine); void run(); }
UpdateMenu implements Runnable { protected static String findMenuItems(String html) { Document doc = Jsoup.parse(html); String menu = ""; Element ul = doc.select("ul").first(); if (ul != null) { for (Element li : ul.children()) { menu += li.select(".food").text() + " " + li.select(".price").text() + " "; } return menu.trim(); } Element p = doc.select("p").first(); if (p != null) { return p.text(); } logger.debug("Unmatched dinner menu: " + html); return "No matches for menu items were found."; } UpdateMenu(MiddagPlugin middagPlugin, String kantine); void run();  }