@Test public void stripEmailWhitespace() throws Exception { when(ldapManager.getUser("test")).thenReturn(user); when(user.getEmail()).thenReturn(" [email protected] "); final User user = underTest.getUser("test"); assertThat(user.getEmailAddress(), is("*****@*****.**")); }
private User toPlexusUser(LdapUser ldapUser) { User user = new DefaultUser(); String email = ldapUser.getEmail(); if (email != null) { email = email.trim(); } user.setEmailAddress(email); user.setName(ldapUser.getRealName()); user.setUserId(ldapUser.getUsername()); user.setSource(USER_SOURCE); user.setStatus(UserStatus.active); for (String roleId : ldapUser.getMembership()) { RoleIdentifier role = new RoleIdentifier(USER_SOURCE, roleId); user.addRole(role); } return user; }