### Question:
HibernateFolderHistoryDAO extends HibernatePersistentObjectDAO<FolderHistory> implements FolderHistoryDAO { @Override public List<FolderHistory> findByPath(String pathExpression, Date olderDate, Collection<String> events, Integer max) { StringBuffer query = new StringBuffer( "(_entity.path like '" + pathExpression + "' or _entity.pathOld like '" + pathExpression + "') "); List<Object> params = new ArrayList<Object>(); if (olderDate != null) { query.append(" and _entity.date >= ?1 "); params.add(olderDate); } if (events != null && !events.isEmpty()) { StringBuffer eventsStr = new StringBuffer("("); for (String event : events) { if (eventsStr.length() > 1) eventsStr.append(","); eventsStr.append("'" + event + "'"); } eventsStr.append(")"); query.append(" and _entity.event in " + eventsStr); } try { return findByWhere(query.toString(), params.toArray(new Object[0]), "order by _entity.date asc", max); } catch (PersistenceException e) { log.error(e.getMessage(), e); return new ArrayList<FolderHistory>(); } } private  HibernateFolderHistoryDAO(); @Override List<FolderHistory> findByUserId(long userId); @Override List<FolderHistory> findByFolderId(long folderId); @Override List<FolderHistory> findNotNotified(Integer max); @Override void cleanOldHistories(int ttl); @Override List<FolderHistory> findByUserIdAndEvent(long userId, String event); @Override boolean store(FolderHistory entity); @Override List<FolderHistory> findByPath(String pathExpression, Date olderDate, Collection<String> events,
			Integer max); @Override List<FolderHistory> findByFolderIdAndEvent(long folderId, String event, Date oldestDate);  }### Answer:
@Test public void testFindByPath() { List<FolderHistory> histories = dao.findByPath("/Default/pippo%", null, null, null); Assert.assertEquals(2, histories.size()); histories = dao.findByPath("/Default/pippo%", DateBean.dateFromCompactString("20061228"), null, null); Assert.assertEquals(1, histories.size()); histories = dao.findByPath("/Default/pippo%", DateBean.dateFromCompactString("20061228"), Arrays.asList(new String[] { "data test 03", "data test 04" }), null); Assert.assertEquals(1, histories.size()); histories = dao.findByPath("/Default/pippo%", DateBean.dateFromCompactString("20061228"), Arrays.asList(new String[] { "data test 043" }), null); Assert.assertEquals(0, histories.size()); histories = dao.findByPath("/xxxx", null, null, null); Assert.assertEquals(0, histories.size()); }