// assertTrue(userDetails.getUsername().equals(user.getEmail()));
// }
@Test
public void loadUserDetailsByEmailTest() {
User user = getUserWithSecurityContext();
userService.add(user);
Set<String> openIdIdentifiers = new HashSet<String>();
openIdIdentifiers.add("oldOpenIdIdentifier");
user.setOpenIdIdentifiers(openIdIdentifiers);
OpenIDAuthenticationToken token = mock(OpenIDAuthenticationToken.class);
when(token.getName()).thenReturn("newOpenIdIdentifier");
List<OpenIDAttribute> attributes = new ArrayList<OpenIDAttribute>();
List<String> attributeValues = new ArrayList<String>();
attributeValues.add(user.getEmail());
OpenIDAttribute attribute = new OpenIDAttribute("email", "", attributeValues);
attributes.add(attribute);
when(token.getAttributes()).thenReturn(attributes);
UserDetails userDetails = userDetailsService.loadUserDetails(token);
assertNotNull(userDetails);
assertTrue(userDetails.getUsername().equals(user.getEmail()));
}