### Question:
HibernateMenuDAO extends HibernatePersistentObjectDAO<Menu> implements MenuDAO { @Override @SuppressWarnings("rawtypes") public boolean isReadEnable(long menuId, long userId) { boolean result = true; try { User user = userDAO.findById(userId); if (user == null) return false; if (user.isMemberOf("admin")) return true; long id = menuId; Menu menu = findById(menuId); if (menu.getSecurityRef() != null) id = menu.getSecurityRef().longValue(); Set<Group> Groups = user.getGroups(); if (Groups.isEmpty()) return false; Iterator iter = Groups.iterator(); StringBuffer query = new StringBuffer("select distinct(_entity) from Menu _entity "); query.append(" left join _entity.menuGroups as _group "); query.append(" where _group.groupId in ("); boolean first = true; while (iter.hasNext()) { if (!first) query.append(","); Group ug = (Group) iter.next(); query.append(Long.toString(ug.getId())); first = false; } query.append(") and _entity.id=?1"); List<MenuGroup> coll = (List<MenuGroup>) findByQuery(query.toString(), new Object[] { Long.valueOf(id) }, null); result = coll.size() > 0; } catch (Exception e) { if (log.isErrorEnabled()) log.error(e.getMessage(), e); result = false; } return result; } protected  HibernateMenuDAO(); UserDAO getUserDAO(); void setUserDAO(UserDAO userDAO); @Override boolean store(Menu menu); @Override @SuppressWarnings("rawtypes") List<Menu> findByUserId(long userId); @Override List<Menu> findByUserId(long userId, long parentId); @SuppressWarnings("rawtypes") List<Menu> findByUserId(long userId, long parentId, Integer type); @Override List<Menu> findChildren(long parentId, Integer max); @SuppressWarnings("rawtypes") @Override List<Menu> findChildren(long parentId, long userId); List<Menu> findByParentId(long parentId); @Override @SuppressWarnings("rawtypes") boolean isWriteEnable(long menuId, long userId); @Override @SuppressWarnings("rawtypes") boolean isReadEnable(long menuId, long userId); @Override String findNameById(long menuId); @Override List<Long> findMenuIdByUserId(long userId); int isMenuWriteable(long menuId, long userId); @Override boolean hasWriteAccess(Menu menu, long userId); @Override List<Menu> findByGroupId(long groupId); @SuppressWarnings("rawtypes") List<Long> findIdByUserId(long userId, long parentId, Integer type); @Override List<Menu> findByName(String name); @Override List<Menu> findByName(Menu parent, String name, boolean caseSensitive); @Override String computePathExtended(long menuId); @Override List<Menu> findByNameAndParentId(String name, long parentId); @Override List<Menu> findParents(long menuId); @Override void restore(long menuId, boolean parents); @Override List<Long> findMenuIdByUserIdAndPermission(long userId, Permission permission); @Override void deleteAll(Collection<Menu> menus); @Override boolean delete(long menuId, int code); @Override boolean applyRightToTree(long id); @SuppressWarnings("rawtypes") @Override List<Long> findIdByUserId(long userId, long parentId);  }### Answer:
@Test public void testIsReadEnable() { Assert.assertTrue(dao.isReadEnable(2, 1)); Assert.assertTrue(dao.isReadEnable(26, 1)); Assert.assertFalse(dao.isReadEnable(2, 22)); Assert.assertFalse(dao.isReadEnable(2, 999)); Assert.assertTrue(dao.isReadEnable(1200, 4)); }