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