HTMLParser { public long mainLoop(){ long result = this.startDate; long timeDate = 0; boolean next = true; int numberPage = 1; Document document = null; Elements rows = null; Elements oldRows = null; do{ document = getHtmlPage(String.format("%s/%d",this.url,numberPage++)); rows = getRowTable(getTableHtml(document)); for (Element element : rows) { Elements cols = element.select("td:not(.icon_cell)"); Elements sp = cols.select("span.closedTopic"); if (sp.isEmpty()) { timeDate = parseElementToVacancy(cols); if (result < timeDate) { result = timeDate; } } } if(!this.firstLoad && result > this.startDate ||rows != null && ((rows.size() == 3) && (oldRows.size() ==3))) { next = false; }else { oldRows = rows; } }while (next); return result; } HTMLParser(DBManager storage); Document getHtmlPage(String url); Elements getTableHtml(Document document); Elements getRowTable(Elements elements); boolean checkVacancy(String textVacancy); void addVacancy(String linkVacancy, String nameVacancy, String author, String linkAuthor, int ask, int view, long timeUpdate); long convertation(String time); String cleanNameVacancy(String name); long parseElementToVacancy(Elements column); long mainLoop();  }
@Test public void checkMainLoop() throws Exception { Properties properties = new Properties(); try (FileInputStream fileInputStream = new FileInputStream(this.getClass().getClassLoader().getResource("vacancy.properties").getPath())) { properties.load(fileInputStream); } catch (FileNotFoundException e) { } catch (IOException e) { } HTMLParser parser = new HTMLParser(new DBManager(properties)); long time = parser.mainLoop(); }