### Question:
HibernateSystemMessageDAO extends HibernatePersistentObjectDAO<SystemMessage> implements SystemMessageDAO { @Override public List<SystemMessage> findByType(int type) { String sql = "select ld_lastmodified, ld_author, ld_messagetext, ld_subject, ld_sentdate, ld_datescope, ld_prio, ld_confirmation, ld_lastnotified, ld_status, ld_trials, ld_type, ld_id, ld_html, ld_author, ld_tenantid " + " from ld_systemmessage where ld_deleted = 0 and ld_id IN (select ld_messageid from ld_recipient where ld_type = " + type + ") order by ld_sentdate desc"; try { List<SystemMessage> messages = (List<SystemMessage>) query(sql, null, new SystemMessageMapper(), null); return messages; } catch (PersistenceException e) { log.error(e.getMessage(), e); return new ArrayList<SystemMessage>(); } } HibernateSystemMessageDAO(); @Override List<SystemMessage> findByRecipient(String recipient, int type, Integer read); @Override int getUnreadCount(String recipient, int type); void deleteExpiredMessages(String recipient); void deleteExpiredMessages(int type); @Override List<SystemMessage> findByMode(String mode); @Override List<SystemMessage> findByType(int type); @Override void initialize(SystemMessage message); @Override List<SystemMessage> findMessagesToBeSent(int type, int maxTrial); @Override boolean store(SystemMessage message);  }### Answer:
@Test public void testFindByType() { Collection<SystemMessage> coll = dao.findByType(0); Assert.assertEquals(2, coll.size()); coll = dao.findByType(1); Assert.assertEquals(2, coll.size()); coll = dao.findByType(2); Assert.assertEquals(1, coll.size()); coll = dao.findByType(3); Assert.assertEquals(0, coll.size()); }