Esempio n. 1
0
  @Test
  public void testGetNumberOfNewsThisDay() throws Exception {
    News news1 = new News("N1", "ASdfg1");
    News news2 = new News("N2", "ASdfg2");
    News news3 = new News("N3", "ASdfg3");

    entityTransaction = entityManagerNews.getTransaction();
    entityTransaction.begin();
    newsEJB.createNews(news1);
    newsEJB.createNews(news2);
    newsEJB.createNews(news3);
    entityTransaction.commit();

    int numberOfNewsThisDay = newsStatistics.getNumberOfNewsThisDay();

    assertEquals(3, numberOfNewsThisDay);
  }
Esempio n. 2
0
  @Before
  public void setUp() throws Exception {
    entityManagerFactory = Persistence.createEntityManagerFactory(DatabaseConfig.database_name);

    entityManagerNews = entityManagerFactory.createEntityManager();
    entityManagerComment = entityManagerFactory.createEntityManager();

    newsEJB = new NewsEJB(entityManagerNews);
    commentEJB = new CommentEJB(entityManagerComment);

    newsStatistics = new NewsStatistics();
    newsStatistics.setNewsEJB(newsEJB);
    news = newsEJB.getNewsById(1);
  }
Esempio n. 3
0
  @Ignore
  @Test
  public void testGetNumberOfCountriesOnOneNews() throws Exception {
    NewsStatistics newsStatistics = new NewsStatistics();
    newsStatistics.setNewsEJB(newsEJB);

    news.addComment(commentEJB.getCommentById(1));
    news.addComment(commentEJB.getCommentById(2));
    news.addComment(commentEJB.getCommentById(3));

    News updatedNews = newsEJB.getNewsById(1);

    int numberOfCountries = newsStatistics.getNumberOfCountriesOnOneNews(updatedNews);

    assertEquals(2, numberOfCountries);
  }