@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);
  }
  private Library createSimpleLibrary() {
    SourceanalysatorFactory factory = SourceanalysatorFactory.eINSTANCE;
    Library library = factory.createLibrary();

    // create sources
    spiegel = factory.createGeneralSource();
    spiegel.setName("Spiegel");
    library.getGeneralSources().add(spiegel);

    guardian = factory.createGeneralSource();
    guardian.setName("Guardian");
    library.getGeneralSources().add(guardian);

    Source spiegel1 = factory.createSource();
    spiegel1.setUrl("http://www.spon.de/crap");
    spiegel1.setGeneralSource(spiegel);
    library.getSources().add(spiegel1);

    Source spiegel2 = factory.createSource();
    spiegel2.setUrl("http://www.spiegel.de/trash");
    spiegel2.setGeneralSource(spiegel);
    library.getSources().add(spiegel2);

    Source guardian1 = factory.createSource();
    guardian1.setUrl("http://www.guardian.com/article1");
    guardian1.setGeneralSource(guardian);
    library.getSources().add(guardian1);

    // create articles
    Article article1 = factory.createArticle();
    article1.setTitle("F**k the system");
    article1.getSources().add(spiegel1);
    article1.getSources().add(spiegel2);
    article1.getSources().add(guardian1);
    library.getArticles().add(article1);

    Article article2 = factory.createArticle();
    article2.setTitle(ARTICLE_TITLE);
    article2.getSources().add(spiegel2);
    article2.getSources().add(guardian1);
    library.getArticles().add(article2);

    return library;
  }