Search in sources :

Example 71 with User

use of org.olat.core.id.User in project openolat by klemens.

the class UserDAOTest method shouldNotReturnUniqueUserIfManyFound.

@Test
public void shouldNotReturnUniqueUserIfManyFound() {
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao");
    String email = identity.getUser().getEmail();
    User userWithSameEmail = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao").getUser();
    userWithSameEmail.setProperty(UserConstants.EMAIL, email);
    userManager.updateUser(userWithSameEmail);
    Identity foundIdentity = sut.findUniqueIdentityByEmail(email);
    assertThat(foundIdentity).isNull();
}
Also used : User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 72 with User

use of org.olat.core.id.User in project openolat by klemens.

the class UserDAOTest method shouldNotReturnUniqueUserIfManyFoundInInstitutionalEmail.

@Test
public void shouldNotReturnUniqueUserIfManyFoundInInstitutionalEmail() {
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao");
    String email = identity.getUser().getEmail();
    User userWithInstitutionalEmail = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao").getUser();
    userWithInstitutionalEmail.setProperty(UserConstants.INSTITUTIONALEMAIL, email);
    userManager.updateUser(userWithInstitutionalEmail);
    Identity foundIdentity = sut.findUniqueIdentityByEmail(email);
    assertThat(foundIdentity).isNull();
}
Also used : User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 73 with User

use of org.olat.core.id.User in project openolat by klemens.

the class UserDAOTest method shouldReturnUniqueUserIfFoundInInstitutionalEmail.

@Test
public void shouldReturnUniqueUserIfFoundInInstitutionalEmail() {
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao");
    String institutionalEmail = UUID.randomUUID() + "@trashmail.com";
    User user = identity.getUser();
    user.setProperty(UserConstants.INSTITUTIONALEMAIL, institutionalEmail);
    userManager.updateUser(user);
    Identity foundIdentity = sut.findUniqueIdentityByEmail(institutionalEmail);
    assertThat(foundIdentity).isNotNull().isEqualTo(identity);
}
Also used : User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 74 with User

use of org.olat.core.id.User in project openolat by klemens.

the class UserDAOTest method shouldReturnIfEmailIsInInstitutionalEmailInUse.

@Test
public void shouldReturnIfEmailIsInInstitutionalEmailInUse() {
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao");
    User user = identity.getUser();
    String institutionalEmail = "INSTITUTION@openolat.org";
    user.setProperty(UserConstants.INSTITUTIONALEMAIL, institutionalEmail);
    userManager.updateUser(user);
    boolean isInUse = sut.isEmailInUse(institutionalEmail);
    assertThat(isInUse).isTrue();
}
Also used : User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 75 with User

use of org.olat.core.id.User in project openolat by klemens.

the class UserDAOTest method shouldReturnIdentitiesWithoutEmail.

@Test
public void shouldReturnIdentitiesWithoutEmail() {
    Identity identityWithoutEmail1 = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao");
    User userWithoutEmail1 = identityWithoutEmail1.getUser();
    userWithoutEmail1.setProperty(UserConstants.EMAIL, null);
    userManager.updateUser(userWithoutEmail1);
    Identity identityWithoutEmailDeleted = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao");
    User userWithoutEmailDeleted = identityWithoutEmailDeleted.getUser();
    userWithoutEmailDeleted.setProperty(UserConstants.EMAIL, null);
    userManager.updateUser(userWithoutEmailDeleted);
    UserDeletionManager.getInstance().deleteIdentity(identityWithoutEmailDeleted);
    Identity identityWithoutEmail2 = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao");
    User userWithoutEmail2 = identityWithoutEmail2.getUser();
    userWithoutEmail2.setProperty(UserConstants.EMAIL, null);
    userManager.updateUser(userWithoutEmail2);
    Identity identityWithEmail = JunitTestHelper.createAndPersistIdentityAsRndUser("userdao");
    List<Identity> identtitiesWithoutEmail = sut.findVisibleIdentitiesWithoutEmail();
    assertThat(identtitiesWithoutEmail).contains(identityWithoutEmail1, identityWithoutEmail2).doesNotContain(identityWithoutEmailDeleted, identityWithEmail);
}
Also used : User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) 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