@Test
@Transactional
public void test_ldapUserDetailsService_groups_and_profiles_admin() throws NamingException {

    //make sure its already in the repository, or nothing will happen
    Group group = new Group().setName("GENERAL");
    group = groupRepository.save(group);
    UserDetails details = ldapUserDetailsService.loadUserByUsername("admin@example.com");
    assertNotNull(details);
    LDAPUser user1 = (LDAPUser) details;
    assertEquals(1, user1.getPrivileges().size());
    assertTrue(user1.getPrivileges().containsKey("GENERAL"));
    assertEquals(1, user1.getPrivileges().get("GENERAL").toArray().length);
    assertEquals(Profile.Administrator, user1.getPrivileges().get("GENERAL").toArray()[0]);
    User user = userRepository.findOneByUsername("admin@example.com");
    assertNotNull(user);
    assertEquals("admin", user.getSurname());
    assertEquals(Profile.Administrator, user.getProfile());
    List<UserGroup> ug = userGroupRepository.findAll(UserGroupSpecs.hasUserId(user.getId()));
    assertNotNull(ug);
    assertEquals(1, ug.size());
    assertEquals("GENERAL", ug.get(0).getGroup().getName());
}