@Test
  public void sessionProcessedNewsReporter() {
    this.clearDatabase();
    User u = TeztBeanSimpleFactory.getAdmin();
    u.insert();
    NewsSource nr = new NewsSourceForSessionProcessed();
    assertNotNull(nr);
    List<NewsItem> nis = nr.getNews(SimpleTimeFrame.getToday(), u);
    int nis_size_before = nis.size();

    // insert a processed session
    TimeBooking booking = TeztBeanSimpleFactory.getNewValidBooking();
    booking.getSessionTimeFrame().add(Calendar.YEAR, 1);
    booking.setBooked();
    booking.setUsername(u.getUsername());
    booking.insert();
    booking.processSession();
    Job document = new Job();
    document.setJobId(booking.getId());
    document.setUsername(u.getUsername());
    document.setStep(2);
    document.setIdJobDataProcessing("foo");
    document.setJobSurvey(new JSONObject());
    document.insertOrUpdate();

    // the test
    nis = nr.getNews(SimpleTimeFrame.getToday(), u);
    assertEquals(nis_size_before + 1, nis.size());
  }
 @Test
 public void constructNewsReporter() {
   try {
     NewsSource nr = new NewsSourceForNewUser();
     assertNotNull(nr);
     @SuppressWarnings("unused")
     List<NewsItem> nis = nr.getNews(SimpleTimeFrame.getToday(), TeztBeanSimpleFactory.getAdmin());
     assertTrue("successed", true);
   } catch (Exception e) {
     fail("should not throw exception");
   }
 }
  @Test
  public void logbookNewsReporter() {
    try {
      NewsSource nr = new NewsSourceForLogbookEntries(false);
      assertNotNull(nr);
      List<NewsItem> nis = nr.getNews(SimpleTimeFrame.getToday(), TeztBeanSimpleFactory.getAdmin());
      int nis_size_before = nis.size();
      int assertNewLogbookEntries = 0;

      LogbookEntry logbook = TeztBeanSimpleFactory.getNewValidLogbookEntry();
      assertNewLogbookEntries++; // because a new user was inserted
      logbook.setLogbookId(TeztBeanSimpleFactory.LOGBOOK_ID1);
      logbook.setDate(new Date());
      logbook.insert();
      assertNewLogbookEntries++; // because a new logbook was inserted

      assertNotNull(logbook.getDate());

      nis = nr.getNews(SimpleTimeFrame.getToday(), TeztBeanSimpleFactory.getAdmin());
      assertEquals(nis_size_before + assertNewLogbookEntries, nis.size());

      // assert same date as lobook entry
      NewsItem back = nis.get(nis.size() - 1);
      assertEquals(back.getEventStarts().toString(), logbook.getDate().toString());

      // update entry to past
      Calendar last_year = Calendar.getInstance();
      last_year.add(Calendar.YEAR, -1);
      logbook.setDate(last_year.getTime());
      logbook.update();

      nis = nr.getNews(SimpleTimeFrame.getToday(), TeztBeanSimpleFactory.getAdmin());
      assertEquals(nis_size_before + 1, nis.size()); // + 1 because of adminLogbook still there

      assertTrue("successed", true);
    } catch (Exception e) {
      fail("should not throw exception");
    }
  }