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);
}
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();
}
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);
}
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"));
}
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));
}
Aggregations