@Test public void getNews() throws Exception { List<NewsEntry> entries = testee.getNews(); assertThat(entries.size(), is(3)); assertThat(entries.get(0).getNewsAsMarkdown(), is("news3.0.0")); assertThat(entries.get(0).getShowForVersion().major, is(3)); }
public List<NewsEntry> getNews() throws IOException { if (Instant.now().minus(2, ChronoUnit.HOURS).isAfter(lastCheckedForNews)) { newsEntries = webAccess.callUrl(newsUrl, new TypeReference<List<NewsEntry>>() { }); newsEntries.sort(Comparator.comparing(NewsEntry::getShowForVersion).reversed()); lastCheckedForNews = Instant.now(); } return newsEntries; }
NewsProvider { public List<NewsEntry> getNews() throws IOException { if (Instant.now().minus(2, ChronoUnit.HOURS).isAfter(lastCheckedForNews)) { newsEntries = webAccess.callUrl(newsUrl, new TypeReference<List<NewsEntry>>() { }); newsEntries.sort(Comparator.comparing(NewsEntry::getShowForVersion).reversed()); lastCheckedForNews = Instant.now(); } return newsEntries; } }
NewsProvider { public List<NewsEntry> getNews() throws IOException { if (Instant.now().minus(2, ChronoUnit.HOURS).isAfter(lastCheckedForNews)) { newsEntries = webAccess.callUrl(newsUrl, new TypeReference<List<NewsEntry>>() { }); newsEntries.sort(Comparator.comparing(NewsEntry::getShowForVersion).reversed()); lastCheckedForNews = Instant.now(); } return newsEntries; }  }
NewsProvider { public List<NewsEntry> getNews() throws IOException { if (Instant.now().minus(2, ChronoUnit.HOURS).isAfter(lastCheckedForNews)) { newsEntries = webAccess.callUrl(newsUrl, new TypeReference<List<NewsEntry>>() { }); newsEntries.sort(Comparator.comparing(NewsEntry::getShowForVersion).reversed()); lastCheckedForNews = Instant.now(); } return newsEntries; }  List<NewsEntry> getNews(); void saveShownForCurrentVersion(); List<NewsEntry> getNewsForCurrentVersionAndAfter(); }
NewsProvider { public List<NewsEntry> getNews() throws IOException { if (Instant.now().minus(2, ChronoUnit.HOURS).isAfter(lastCheckedForNews)) { newsEntries = webAccess.callUrl(newsUrl, new TypeReference<List<NewsEntry>>() { }); newsEntries.sort(Comparator.comparing(NewsEntry::getShowForVersion).reversed()); lastCheckedForNews = Instant.now(); } return newsEntries; }  List<NewsEntry> getNews(); void saveShownForCurrentVersion(); List<NewsEntry> getNewsForCurrentVersionAndAfter();  }