User user = new UserImpl("123", 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);