/** * return an {@link LogbookEntry} with an admin as author, current date, english as language. * * @since 06.03.2014 * @return base {@link LogbookEntry} for all entries made here */ private LogbookEntry getNewBaseEntry() { LogbookEntry result = new LogbookEntry(); result.setOfUserName(RoleConfigDao.getInstance().getUsernamesOfAdmins()[0]); result.setLogbookId(this.getKey()); result.setTagsFromCsv("system"); result.setDate(); result.setLanguage(Locale.ENGLISH); return result; }
@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"); } }
public List<LogbookEntry> getAllEntries() { LogbookEntry le = new LogbookEntry(); le.setLogbookId(this.getKey()); return FamDaoProxy.logbookEntryDao().getObjectsLike(le); }