DefaultPersistenceManager implements PersistenceManager<T, I> { @Override public T update(final T entity) { LOG.info("Updating entity for class:{}", entity.getClass()); verify(DaoMethod.UPDATE, entity); return entityManager.merge(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 testUpdate() throws Exception { Long id = 1L; String name = "name"; String abbrName = "abbrName"; String group = "developers"; Department expected = new Department(); expected.setId(id); expected.setAbbrName(abbrName); expected.setName(name); expected.setCrtUserGroup(group); when(entityManager.merge(any(Department.class))).thenReturn(expected); Department actual = unit.update(expected); verify(updateVerifier).verify(expected); verify(entityManager).merge(expected); assertEquals(expected, actual); }