@Test public void testFindMenuEmptyMenu() { String filename = "/middag/emptyMenu.html"; String html = readResourceFile(filename); assertEquals( "Ingen meny tilgjengelig", 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();  }