DataGroupServiceImpl extends BaseGenericServiceImpl<DataGroup> implements DataGroupService { @Override public DataGroup findByName(final String name) { final List<DataGroup> groups = getGenericDao().findByNamedQuery("DATAGROUP.BY.NAME", name); if (groups.isEmpty()) { return null; } return groups.get(0); } DataGroupServiceImpl(final GenericDAO<DataGroup, Long> genericDao); @Override List<DataGroup> findByType(final String type); @Override DataGroup findByName(final String name);  }
@Test public void testFindByName() throws Exception { assertNull(dataGroupService.findByName("G005")); final DataGroup group005 = dataGroupService.getGenericDao().getEntityFactory().getByIface(DataGroup.class); group005.setName("G005"); group005.setType("FindByName"); group005.setDescriptors("d1,d2,d3"); dataGroupService.create(group005); final DataGroup g005search = dataGroupService.findByName("G005"); assertNotNull(g005search); assertEquals("G005", g005search.getName()); }