use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.
the class MailServiceIntTest method testSendEmailFromTemplate.
@Test
public void testSendEmailFromTemplate() throws Exception {
User user = new User();
user.setLogin("john");
user.setEmail("john.doe@example.com");
user.setLangKey("en");
mailService.sendEmailFromTemplate(user, "testEmail", "email.test.title");
verify(javaMailSender).send((MimeMessage) messageCaptor.capture());
MimeMessage message = (MimeMessage) messageCaptor.getValue();
assertThat(message.getSubject()).isEqualTo("test title");
assertThat(message.getAllRecipients()[0].toString()).isEqualTo(user.getEmail());
assertThat(message.getFrom()[0].toString()).isEqualTo("test@localhost");
assertThat(message.getContent().toString()).isEqualTo("<html>test title, http://127.0.0.1:8080, john</html>\n");
assertThat(message.getDataHandler().getContentType()).isEqualTo("text/html;charset=UTF-8");
}
use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.
the class MailServiceIntTest method testSendActivationEmail.
@Test
public void testSendActivationEmail() throws Exception {
User user = new User();
user.setLangKey(Constants.DEFAULT_LANGUAGE);
user.setLogin("john");
user.setEmail("john.doe@example.com");
mailService.sendActivationEmail(user);
verify(javaMailSender).send((MimeMessage) messageCaptor.capture());
MimeMessage message = (MimeMessage) messageCaptor.getValue();
assertThat(message.getAllRecipients()[0].toString()).isEqualTo(user.getEmail());
assertThat(message.getFrom()[0].toString()).isEqualTo("test@localhost");
assertThat(message.getContent().toString()).isNotEmpty();
assertThat(message.getDataHandler().getContentType()).isEqualTo("text/html;charset=UTF-8");
}
use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.
the class SocialServiceIntTest method testCreateSocialUserShouldNotChangeUserIfEmailAlreadyExist.
@Test
public void testCreateSocialUserShouldNotChangeUserIfEmailAlreadyExist() {
// Setup
createExistingUser("@OTHER_LOGIN", "mail@mail.com", "OTHER_FIRST_NAME", "OTHER_LAST_NAME", "OTHER_IMAGE_URL");
Connection<?> connection = createConnection("@LOGIN", "mail@mail.com", "FIRST_NAME", "LAST_NAME", "IMAGE_URL", "PROVIDER");
// Exercise
socialService.createSocialUser(connection, "fr");
// Verify
User userToVerify = userRepository.findOneByEmailIgnoreCase("mail@mail.com").get();
assertThat(userToVerify.getLogin()).isEqualTo("@other_login");
assertThat(userToVerify.getFirstName()).isEqualTo("OTHER_FIRST_NAME");
assertThat(userToVerify.getLastName()).isEqualTo("OTHER_LAST_NAME");
assertThat(userToVerify.getImageUrl()).isEqualTo("OTHER_IMAGE_URL");
// Teardown
userRepository.delete(userToVerify);
}
use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.
the class SocialServiceIntTest method testCreateSocialUserShouldCreateUserWithSocialInformation.
@Test
public void testCreateSocialUserShouldCreateUserWithSocialInformation() {
// Setup
Connection<?> connection = createConnection("@LOGIN", "mail@mail.com", "FIRST_NAME", "LAST_NAME", "IMAGE_URL", "PROVIDER");
// Exercise
socialService.createSocialUser(connection, "fr");
// Verify
User user = userRepository.findOneByEmailIgnoreCase("mail@mail.com").get();
assertThat(user.getFirstName()).isEqualTo("FIRST_NAME");
assertThat(user.getLastName()).isEqualTo("LAST_NAME");
assertThat(user.getImageUrl()).isEqualTo("IMAGE_URL");
// Teardown
userRepository.delete(user);
}
use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.
the class SocialServiceIntTest method testCreateSocialUserShouldNotCreateUserIfEmailAlreadyExist.
@Test
public void testCreateSocialUserShouldNotCreateUserIfEmailAlreadyExist() {
// Setup
createExistingUser("@OTHER_LOGIN", "mail@mail.com", "OTHER_FIRST_NAME", "OTHER_LAST_NAME", "OTHER_IMAGE_URL");
long initialUserCount = userRepository.count();
Connection<?> connection = createConnection("@LOGIN", "mail@mail.com", "FIRST_NAME", "LAST_NAME", "IMAGE_URL", "PROVIDER");
// Exercise
socialService.createSocialUser(connection, "fr");
// Verify
assertThat(userRepository.count()).isEqualTo(initialUserCount);
// Teardown
User userToDelete = userRepository.findOneByEmailIgnoreCase("mail@mail.com").get();
userRepository.delete(userToDelete);
}
Aggregations