Search in sources :

Example 36 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class ShibbolethAttributesTest method shouldChangePropertyOfSyncedUserIfItWasNotPresent.

@Test
public void shouldChangePropertyOfSyncedUserIfItWasNotPresent() {
    User user = getIdenticalOlatUser();
    user.setProperty(USER_NAME_KEY, null);
    User syncedUser = sut.syncUser(user);
    assertThat(syncedUser.getProperty(USER_CITY_KEY, null)).isEqualTo(SHIB_CITY_VALUE_NULL);
}
Also used : User(org.olat.core.id.User) Test(org.junit.Test)

Example 37 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class UserManagerImplTest method shouldAllowEmailIfItsOwnEmail.

@Test
public void shouldAllowEmailIfItsOwnEmail() {
    when(userModuleMock.isEmailUnique()).thenReturn(true);
    when(userModuleMock.isEmailMandatory()).thenReturn(true);
    User myselfMock = mock(User.class);
    when(myselfMock.getEmail()).thenReturn(DUPLICATE_EMAIL);
    boolean isEmailAllowed = sut.isEmailAllowed(DUPLICATE_EMAIL, myselfMock);
    assertThat(isEmailAllowed).isTrue();
}
Also used : User(org.olat.core.id.User) Test(org.junit.Test)

Example 38 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class UserManagerImplTest method shouldEnsureEmailIfHasNoEmail.

@Test
public void shouldEnsureEmailIfHasNoEmail() {
    Long userKey = 123l;
    String issuer = "issuer";
    AuthenticationProvider authenticationProviderMock = mock(AuthenticationProvider.class);
    when(authenticationProviderMock.getIssuerIdentifier(any())).thenReturn(issuer);
    when(loginModuleMock.getAuthenticationProvider("OLAT")).thenReturn(authenticationProviderMock);
    User userWithoutEmailMock = mock(User.class);
    when(userWithoutEmailMock.getKey()).thenReturn(userKey);
    String ensuredEmail = sut.getEnsuredEmail(userWithoutEmailMock);
    String expectedValue = userKey + "@" + issuer;
    assertThat(ensuredEmail).isEqualTo(expectedValue);
}
Also used : User(org.olat.core.id.User) AuthenticationProvider(org.olat.login.auth.AuthenticationProvider) Test(org.junit.Test)

Example 39 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class UserTest method testSetUserProfile.

/**
 * test if user profile does work
 * @throws Exception
 */
@Test
public void testSetUserProfile() throws Exception {
    // preferences that are not set to a value must not return null
    // The preferences object itself must not be null - a user always has
    // a preferences object
    String fs = u1.getPreferences().getLanguage();
    assertTrue(fs != null);
    // change preferences values and look it up (test only one
    // attribute, we assume that getters and setters do work!)
    u1.getPreferences().setLanguage("de");
    userManager.updateUser(u1);
    User u1test = userManager.loadUserByKey(u1.getKey());
    assertTrue(u1test.getPreferences().getLanguage().matches("de"));
}
Also used : User(org.olat.core.id.User) Test(org.junit.Test)

Example 40 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class UserTest method testEquals.

@Test
public void testEquals() {
    User user1 = userManager.findUniqueIdentityByEmail("salat@id.salat.uzh.ch").getUser();
    User user2 = userManager.findUniqueIdentityByEmail("migros@id.migros.uzh.ch").getUser();
    User user1_2 = userManager.findUniqueIdentityByEmail("salat@id.salat.uzh.ch").getUser();
    assertFalse("Wrong equals implementation, different types are recognized as equals ", user1.equals(new Integer(1)));
    assertFalse("Wrong equals implementation, different users are recognized as equals ", user1.equals(user2));
    assertFalse("Wrong equals implementation, null value is recognized as equals ", user1.equals(null));
    assertTrue("Wrong equals implementation, same users are NOT recognized as equals ", user1.equals(user1));
    assertTrue("Wrong equals implementation, same users are NOT recognized as equals ", user1.equals(user1_2));
}
Also used : User(org.olat.core.id.User) Test(org.junit.Test)

Aggregations

User (org.olat.core.id.User)260 Identity (org.olat.core.id.Identity)126 Test (org.junit.Test)82 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)52 HashMap (java.util.HashMap)28 Translator (org.olat.core.gui.translator.Translator)26 SecurityGroup (org.olat.basesecurity.SecurityGroup)20 Date (java.util.Date)18 ArrayList (java.util.ArrayList)16 Locale (java.util.Locale)16 FormItem (org.olat.core.gui.components.form.flexible.FormItem)16 File (java.io.File)14 VelocityContext (org.apache.velocity.VelocityContext)14 MailTemplate (org.olat.core.util.mail.MailTemplate)12 LDAPUser (org.olat.ldap.model.LDAPUser)12 UserManager (org.olat.user.UserManager)12 IOException (java.io.IOException)10 Map (java.util.Map)10 List (java.util.List)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8