when(session.createCriteria(anyString())).thenReturn(criteria);
SessionFactory sessionFactory = mock(SessionFactory.class);
when(sessionFactory.getCurrentSession()).thenReturn(session);
ReflectionHelper reflectionHelper = mock(ReflectionHelper.class);
for (CrysonTestEntity entity : entities) {
when(reflectionHelper.getPrimaryKey(entity)).thenReturn(entity.getId());
}
CrysonRepository crysonRepository = new CrysonRepository();
crysonRepository.setSessionFactory(sessionFactory);
crysonRepository.setReflectionHelper(reflectionHelper);