### Question:
HibernateUserHistoryDAO extends HibernatePersistentObjectDAO<UserHistory> implements UserHistoryDAO { @Override public boolean store(UserHistory history) throws PersistenceException { if (RunLevel.current().aspectEnabled(DocumentHistory.ASPECT)) { boolean ret = super.store(history); if (ret) EventCollector.get().newEvent(history); return ret; } else return true; } private  HibernateUserHistoryDAO(); List<UserHistory> findByUserId(long userId); @Override void createUserHistory(User user, String eventType, String comment, String ip, String sessionId); @Override void cleanOldHistories(int ttl); @Override boolean store(UserHistory history);  }### Answer:
@Test public void testStore() throws PersistenceException { UserHistory userHistory = new UserHistory(); userHistory.setDate(DateBean.dateFromCompactString("20061220")); userHistory.setUsername("sebastian"); userHistory.setUserId(3L); userHistory.setEvent("first test User History store"); Assert.assertTrue(dao.store(userHistory)); UserHistory newUserHistory = new UserHistory(); newUserHistory.setDate(DateBean.dateFromCompactString("20061220")); newUserHistory.setUsername("sebastian"); newUserHistory.setUserId(3L); newUserHistory.setEvent("second test User History store"); Assert.assertTrue(dao.store(newUserHistory)); Collection<UserHistory> histories = (Collection<UserHistory>) dao.findByUserId(3); Assert.assertNotNull(histories); Assert.assertFalse(histories.isEmpty()); UserHistory hStored = null; for (UserHistory userHistory2 : histories) { if (userHistory2.getId() == newUserHistory.getId()) { hStored = userHistory2; break; } } Assert.assertTrue(hStored.equals(newUserHistory)); Assert.assertEquals(hStored.getDate().getTime(), DateBean.dateFromCompactString("20061220").getTime()); Assert.assertEquals(hStored.getUsername(), "sebastian"); Assert.assertEquals(hStored.getEvent(), "second test User History store"); }