@Test public void shouldOnlyGetNewstNotNewerThanCurrentVersion() throws Exception { when(updateManagerMock.getCurrentVersionString()).thenReturn("2.0.0"); when(shownNewsRepositoryMock.findAll()).thenReturn(Collections.singletonList(new ShownNews("0.0.1"))); List<NewsEntry> entries = testee.getNewsForCurrentVersionAndAfter(); assertThat(entries.size(), is(2)); assertThat(entries.get(0).getNewsAsMarkdown(), is("news2.0.0")); assertThat(entries.get(1).getNewsAsMarkdown(), is("news1.0.0")); }
public List<NewsEntry> getNewsForCurrentVersionAndAfter() throws IOException { List<ShownNews> shownNews = shownNewsRepository.findAll(); if (shownNews == null || shownNews.isEmpty()) { return Collections.emptyList(); } SemanticVersion from = shownNews.size() == 1 ? new SemanticVersion(shownNews.get(0).getVersion()) : null; SemanticVersion to = new SemanticVersion(updateManager.getCurrentVersionString()); List<NewsEntry> news = getNews(); return news.stream() .filter(x -> isShowNewsEntry(from, to, x)) .collect(Collectors.toList()); }
NewsProvider { public List<NewsEntry> getNewsForCurrentVersionAndAfter() throws IOException { List<ShownNews> shownNews = shownNewsRepository.findAll(); if (shownNews == null || shownNews.isEmpty()) { return Collections.emptyList(); } SemanticVersion from = shownNews.size() == 1 ? new SemanticVersion(shownNews.get(0).getVersion()) : null; SemanticVersion to = new SemanticVersion(updateManager.getCurrentVersionString()); List<NewsEntry> news = getNews(); return news.stream() .filter(x -> isShowNewsEntry(from, to, x)) .collect(Collectors.toList()); } }
NewsProvider { public List<NewsEntry> getNewsForCurrentVersionAndAfter() throws IOException { List<ShownNews> shownNews = shownNewsRepository.findAll(); if (shownNews == null || shownNews.isEmpty()) { return Collections.emptyList(); } SemanticVersion from = shownNews.size() == 1 ? new SemanticVersion(shownNews.get(0).getVersion()) : null; SemanticVersion to = new SemanticVersion(updateManager.getCurrentVersionString()); List<NewsEntry> news = getNews(); return news.stream() .filter(x -> isShowNewsEntry(from, to, x)) .collect(Collectors.toList()); }  }
NewsProvider { public List<NewsEntry> getNewsForCurrentVersionAndAfter() throws IOException { List<ShownNews> shownNews = shownNewsRepository.findAll(); if (shownNews == null || shownNews.isEmpty()) { return Collections.emptyList(); } SemanticVersion from = shownNews.size() == 1 ? new SemanticVersion(shownNews.get(0).getVersion()) : null; SemanticVersion to = new SemanticVersion(updateManager.getCurrentVersionString()); List<NewsEntry> news = getNews(); return news.stream() .filter(x -> isShowNewsEntry(from, to, x)) .collect(Collectors.toList()); }  List<NewsEntry> getNews(); void saveShownForCurrentVersion(); List<NewsEntry> getNewsForCurrentVersionAndAfter(); }
NewsProvider { public List<NewsEntry> getNewsForCurrentVersionAndAfter() throws IOException { List<ShownNews> shownNews = shownNewsRepository.findAll(); if (shownNews == null || shownNews.isEmpty()) { return Collections.emptyList(); } SemanticVersion from = shownNews.size() == 1 ? new SemanticVersion(shownNews.get(0).getVersion()) : null; SemanticVersion to = new SemanticVersion(updateManager.getCurrentVersionString()); List<NewsEntry> news = getNews(); return news.stream() .filter(x -> isShowNewsEntry(from, to, x)) .collect(Collectors.toList()); }  List<NewsEntry> getNews(); void saveShownForCurrentVersion(); List<NewsEntry> getNewsForCurrentVersionAndAfter();  }