MAIL_ATTRIBUTE_NAME, DISPLAY_NAME_ATTRIBUTE_NAME, "columns_3");
}
@Test
public void testMapUserFromContext_new() throws Exception {
DirContextOperations ctx = createMock(DirContextOperations.class);
final String username = "johnldap";
User user = new User(123L, username);
expect(userService.getUserByUsername(username)).andReturn(null).once();
expect(ctx.attributeExists(MAIL_ATTRIBUTE_NAME)).andReturn(true);
expect(ctx.getStringAttribute(MAIL_ATTRIBUTE_NAME)).andReturn("johnldap@example.com").times(2);
expect(ctx.attributeExists(DISPLAY_NAME_ATTRIBUTE_NAME)).andReturn(true);
expect(ctx.getStringAttribute(DISPLAY_NAME_ATTRIBUTE_NAME)).andReturn("John Ldap");
expect(userService.getUserByUsername(username)).andReturn(user).once();
expectLastCall();
replay(userService, ctx);