when(information.getJavaType()).thenReturn(Role.class);
when(em.getEntityManagerFactory()).thenReturn(emf);
when(emf.createEntityManager()).thenReturn(em);
JpaRepositoryFactory factory = new JpaRepositoryFactory(em) {
@Override
@SuppressWarnings("unchecked")
public <T, ID extends Serializable> JpaEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
return (JpaEntityInformation<T, ID>) information;
}
};
repository = factory.getRepository(RoleRepository.class);
}