### Question:
HibernateMessageTemplateDAO extends HibernatePersistentObjectDAO<MessageTemplate> implements MessageTemplateDAO { @Override public MessageTemplate findByNameAndLanguage(String name, String language, long tenantId) { String lang = language; if (StringUtils.isEmpty(lang)) lang = "en"; try { List<MessageTemplate> buf = findByWhere( " _entity.language='" + lang + "' and _entity.name='" + name + "' and _entity.tenantId=" + tenantId, null, null); if (buf != null && !buf.isEmpty()) return buf.get(0); buf = findByWhere(" _entity.language='en' and _entity.name='" + name + "' and _entity.tenantId=" + tenantId, null, null); if (buf != null && !buf.isEmpty()) return buf.get(0); } catch (PersistenceException e) { log.error(e.getMessage(), e); } return null; } HibernateMessageTemplateDAO(); @Override List<MessageTemplate> findByLanguage(String language, long tenantId); @Override List<MessageTemplate> findByTypeAndLanguage(String type, String language, long tenantId); @Override MessageTemplate findByNameAndLanguage(String name, String language, long tenantId); @Override boolean delete(long id, int code); @Override List<MessageTemplate> findByName(String name, long tenantId);  }### Answer:
@Test public void testFindByNameAndLanguage() { Map<String, Object> dictionary = new HashMap<String, Object>(); dictionary.put("username", "pippo"); dictionary.put("xxx", "label"); MessageTemplate tmp = dao.findByNameAndLanguage("test1", "en", 1L); Assert.assertNotNull(tmp); Assert.assertEquals("test1", tmp.getName()); Assert.assertEquals("body pippo label", tmp.getFormattedBody(dictionary)); Assert.assertEquals("subject label", tmp.getFormattedSubject(dictionary)); tmp = dao.findByNameAndLanguage("test1", "de", 1L); Assert.assertNotNull(tmp); Assert.assertEquals("test1", tmp.getName()); Assert.assertEquals("en", tmp.getLanguage()); tmp = dao.findByNameAndLanguage("test1", "it", 1L); Assert.assertNotNull(tmp); Assert.assertEquals("test1", tmp.getName()); Assert.assertEquals("corpo pippo label", tmp.getFormattedBody(dictionary)); Assert.assertEquals("soggetto label", tmp.getFormattedSubject(dictionary)); tmp = dao.findByNameAndLanguage("xxxxxx", "en", 1L); Assert.assertNull(tmp); }