DefaultService implements Service<ENTITY, ENTITYLIST, KEY> { @Override public ENTITY getEntity(final KEY id) { return dao.getEntityById(id); }  @Override void createEntity(final ENTITY entity); @Override ENTITY getEntity(final KEY id); @Override void updateEntity(final ENTITY entity); @Override void removeEntity(final ENTITY entity); @Override PagedResult<ENTITY> getEntities(final MultiplePagedSearch<ENTITYLIST> search); void setDao(final DAO defaultDao); void setParametersExtractor(final ParametersExtractor<ENTITYLIST> parametersExtractor); DAO getDao(); ParametersExtractor<ENTITYLIST> getParametersExtractor();  }
@Test public void testgetEntity() throws Exception { Long id = 1L; String abbrName = "abbr name"; String name = "name"; Department expected = new Department(); expected.setId(id); expected.setAbbrName(abbrName); expected.setName(name); when(defaultDao.getEntityById(anyLong())).thenReturn(expected); Department actual = unit.getEntity(id); verify(defaultDao).getEntityById(id); assertEquals(expected, actual); }