private StandardUserDetailsService getUserDetailsTestService(CoreContext ctx, boolean imEnabled) {
    User u =
        new User() {
          @Override
          public boolean hasPermission(PermissionName permission) {
            return true;
          }
        };
    u.setUserName(USER_NAME);
    u.setUniqueId();
    AddressBookEntry abe = new AddressBookEntry();
    abe.setImId(USER_IM_ID);
    u.setAddressBookEntry(abe);
    u.setSettings(TestHelper.loadSettings("commserver/user-settings.xml"));
    u.setSettingTypedValue("im/im-account", imEnabled);

    AcdContext acdContext = createMock(AcdContext.class);
    StandardUserDetailsService uds = new StandardUserDetailsService();
    uds.setCoreContext(ctx);
    uds.setAcdContext(acdContext);

    ctx.loadUserByUserNameOrAlias(USER_IM_ID);
    expectLastCall().andReturn(null);

    ctx.loadUserByConfiguredImId(USER_IM_ID);
    expectLastCall().andReturn(u);

    acdContext.getUsersWithAgents();
    expectLastCall().andReturn(Collections.emptyList());

    replay(ctx, acdContext);
    return uds;
  }
 public void updateUser(User user) {
   user.setEmailAddress(m_emailAddress);
   user.setAlternateEmailAddress(m_alternateEmailAddress);
   user.setSettingValue(ACTIVE_GREETING, m_activeGreeting.getId());
   user.setSettingValue(BUSY_PROMPT, m_busyPrompt);
   user.setSettingValue(VOICEMAIL_TUI, m_voicemailTui.getValue());
   user.setSettingValue(EXTERNAL_MWI, m_externalMwi);
   user.setSettingValue(PRIMARY_EMAIL_NOTIFICATION, m_attachVoicemailToEmail.getValue());
   user.setSettingValue(PRIMARY_EMAIL_FORMAT, m_emailFormat.name());
   user.setSettingValue(ALT_EMAIL_FORMAT, m_alternateEmailFormat.name());
   user.setSettingValue(
       ALT_EMAIL_NOTIFICATION, m_voicemailToAlternateEmailNotification.getValue());
   user.setSettingValue(IMAP_HOST, m_imapHost);
   user.setSettingValue(IMAP_PORT, m_imapPort);
   user.setSettingTypedValue(IMAP_TLS, m_imapTLS);
   user.setSettingValue(IMAP_PASSWORD, m_imapPassword);
   user.setSettingValue(IMAP_ACCOUNT, m_imapAccount);
   user.setSettingTypedValue(PRIMARY_EMAIL_ATTACH_AUDIO, m_includeAudioAttachment);
   user.setSettingTypedValue(ALT_EMAIL_ATTACH_AUDIO, m_includeAudioAttachmentAlternateEmail);
 }