### Question:
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();  }### Answer:
@Test public void shouldOnlyGetNewsNewerThanShownButNotNewerThanCurrentVersion() throws Exception { when(updateManagerMock.getCurrentVersionString()).thenReturn("2.0.0"); when(shownNewsRepositoryMock.findAll()).thenReturn(Collections.singletonList(new ShownNews("1.0.0"))); List<NewsEntry> entries = testee.getNewsForCurrentVersionAndAfter(); assertThat(entries.size(), is(1)); assertThat(entries.get(0).getNewsAsMarkdown(), is("news2.0.0")); }
@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")); }
@Test public void shouldNoNewsWhenNewInstall() throws Exception { when(updateManagerMock.getCurrentVersionString()).thenReturn("2.0.0"); when(shownNewsRepositoryMock.findAll()).thenReturn(Collections.emptyList()); List<NewsEntry> entries = testee.getNewsForCurrentVersionAndAfter(); assertThat(entries.size(), is(0)); }
@Test public void shouldNotGetNewsWhenAlreadyShown() throws Exception { when(updateManagerMock.getCurrentVersionString()).thenReturn("3.0.0"); when(shownNewsRepositoryMock.findAll()).thenReturn(Collections.singletonList(new ShownNews("3.0.0"))); List<NewsEntry> entries = testee.getNewsForCurrentVersionAndAfter(); assertThat(entries.size(), is(0)); }