@Test public void analyseSingleArticleSourcesTest() { Library library = createSimpleLibrary(); Article article = library.getArticles().get(0); assertThat("name of article", article.getTitle(), is(equalTo("F**k the system"))); ISourceAnalysator analysator = createSourceAnalysator(library); Map<GeneralSource, List<Source>> generalSources = analysator.getGeneralSourcesOfArticle(article); assertThat("general sopurces count", generalSources.size(), is(equalTo(2))); List<GeneralSource> requiredSources = Lists.newArrayList(spiegel, guardian); for (Entry<GeneralSource, List<Source>> entry : generalSources.entrySet()) { GeneralSource generalSource = entry.getKey(); boolean removedGeneralSource = requiredSources.remove(generalSource); assertThat("expected general source was found", removedGeneralSource, is(true)); List<Source> sources = entry.getValue(); if (generalSource.equals(spiegel)) { assertThat( "count of referenced articles of " + generalSource.getName(), sources.size(), is(equalTo(2))); } else if (generalSource.equals(guardian)) { assertThat( "count of referenced articles of " + generalSource.getName(), sources.size(), is(equalTo(1))); } else { fail("wrong general source"); } } printSourcesOfArticles(Lists.newArrayList(article), generalSources); }
@Test public void analyseNullArticleTest() { Article article = null; Library library = createSimpleLibrary(); ISourceAnalysator analysator = createSourceAnalysator(library); Map<GeneralSource, List<Source>> generalSources = analysator.getGeneralSourcesOfArticle(article); assertThat("general sources of null article", generalSources, is(notNullValue())); assertThat("count of general sources of null article", generalSources.size(), is(equalTo(0))); }