DefaultPersistenceManager implements PersistenceManager<T, I> { @Override public T findById(final Class<T> clazz, final I id) { T entity = entityManager.find(clazz, id); if (entity == null) { LOG.error("Entity is deleted, {}, {}", clazz.getSimpleName()); throw new EntityNotFoundException("Entity doesn't exist", clazz, id); } verify(DaoMethod.SINGLE_GET, entity); return entity; }  @Override T create(final T entity); @Override T findById(final Class<T> clazz, final I id); @Override T update(final T entity); @Override void remove(final T entity); @Override PagedResult<T> search(final MultiplePagedQuerySearch<T> request); @Override T getSingleResult(final Query<T> query); @Override List<E> getMultipleResult(final Query<E> query); List<Object[]> executeNativeQuery(String sql); @Override Object[] executeSingleResultNativeQuery(String sql); void setPersistenceChains(final Map<DaoMethod, VerifierChainLink<? super Object>> persistenceChains); void setPersistenceEnhancers(final Map<DaoMethod, Enhancer<? super Object>> persistenceEnhancers);  }
@Test public void testFindById() throws Exception { Long id = 1L; String name = "name"; String abbrName = "abbrName"; String group = "developers"; Class<Department> clazz = Department.class; Department expected = new Department(); expected.setId(id); expected.setAbbrName(abbrName); expected.setName(name); expected.setCrtUserGroup(group); when(entityManager.find(Matchers.<Class<Department>>any(), anyLong())).thenReturn(expected); Department actual = unit.findById(clazz, id); verify(singleGetVerifier).verify(expected); verify(entityManager).find(clazz, id); assertEquals(expected, actual); }