use of io.github.jhipster.sample.domain.User in project jhipster-sample-app-cassandra by jhipster.
the class UserMapper method userFromId.
public User userFromId(String id) {
if (id == null) {
return null;
}
User user = new User();
user.setId(id);
return user;
}
use of io.github.jhipster.sample.domain.User in project jhipster-sample-app-cassandra by jhipster.
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, "mail/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 io.github.jhipster.sample.domain.User in project jhipster-sample-app-cassandra by jhipster.
the class MailServiceIntTest method testCreationEmail.
@Test
public void testCreationEmail() throws Exception {
User user = new User();
user.setLangKey(Constants.DEFAULT_LANGUAGE);
user.setLogin("john");
user.setEmail("john.doe@example.com");
mailService.sendCreationEmail(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 io.github.jhipster.sample.domain.User in project jhipster-sample-app-cassandra by jhipster.
the class MailServiceIntTest method testSendPasswordResetMail.
@Test
public void testSendPasswordResetMail() throws Exception {
User user = new User();
user.setLangKey(Constants.DEFAULT_LANGUAGE);
user.setLogin("john");
user.setEmail("john.doe@example.com");
mailService.sendPasswordResetMail(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 io.github.jhipster.sample.domain.User in project jhipster-sample-app-cassandra by jhipster.
the class AccountResourceIntTest method testChangePasswordWrongExistingPassword.
@Test
@WithMockUser("change-password-wrong-existing-password")
public void testChangePasswordWrongExistingPassword() throws Exception {
User user = new User();
user.setId(UUID.randomUUID().toString());
String currentPassword = RandomStringUtils.random(60);
user.setPassword(passwordEncoder.encode(currentPassword));
user.setLogin("change-password-wrong-existing-password");
user.setEmail("change-password-wrong-existing-password@example.com");
userRepository.save(user);
restMvc.perform(post("/api/account/change-password").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(new PasswordChangeDTO("1" + currentPassword, "new password")))).andExpect(status().isBadRequest());
User updatedUser = userRepository.findOneByLogin("change-password-wrong-existing-password").orElse(null);
assertThat(passwordEncoder.matches("new password", updatedUser.getPassword())).isFalse();
assertThat(passwordEncoder.matches(currentPassword, updatedUser.getPassword())).isTrue();
}
Aggregations