DataGroupServiceImpl extends BaseGenericServiceImpl<DataGroup> implements DataGroupService { @Override public List<DataGroup> findByType(final String type) { return getGenericDao().findByNamedQuery("DATAGROUPS.BY.TYPE", type); } DataGroupServiceImpl(final GenericDAO<DataGroup, Long> genericDao); @Override List<DataGroup> findByType(final String type); @Override DataGroup findByName(final String name);  }
@Test public void testFindByType() throws Exception { int count = dataGroupService.findCountByCriteria(" where e.type = ?1", DataGroup.TYPE_IMPORT); final DataGroup group001 = dataGroupService.getGenericDao().getEntityFactory().getByIface(DataGroup.class); group001.setName("G001"); group001.setType(DataGroup.TYPE_IMPORT); group001.setDescriptors("d1,d2,d3"); dataGroupService.create(group001); assertEquals(count + 1, dataGroupService.findCountByCriteria(" where e.type = ?1", DataGroup.TYPE_IMPORT)); final DataGroup group002 = dataGroupService.getGenericDao().getEntityFactory().getByIface(DataGroup.class); group002.setName("G002"); group002.setType("OTHER"); group002.setDescriptors("d1,d2,d3"); dataGroupService.create(group002); assertEquals(count + 1, dataGroupService.findCountByCriteria(" where e.type = ?1", DataGroup.TYPE_IMPORT)); final DataGroup g001 = dataGroupService.findByName("G001"); assertEquals("G001", g001.getName()); final List<DataGroup> g002search = dataGroupService.findByType("OTHER"); assertFalse(g002search.isEmpty()); final DataGroup g002 = g002search.get(0); assertEquals("G002", g002.getName()); }