UserNotificationService { public void sendActivationMail(UserEntity user) { String activationLink = buildLink(ACTIVATION_LINK_PATTERN, user.getEmail(), user.getActivationToken()); LOG.debug("Sending activation link {} to {}", activationLink, user.getEmail()); StandardEvaluationContext context = new StandardEvaluationContext(); context.setVariable("link", activationLink); context.setVariable("firstName", user.getFirstName()); final String mailContent = activationEmailTemplate.getValue(context, String.class); sendMail(user.getEmail(), SUBJECT_ACTIVATION, mailContent); }  void sendActivationMail(UserEntity user); void sendPasswordRecoveryMail(UserEntity user); void notifyCreatorOnProjectStatusUpdate(ProjectEntity project); void notifyCreatorOnComment(CommentEntity comment); void notifyCreatorOnIdeaAccepted(IdeaEntity idea, String campaignTitle); void notifyCreatorOnIdeaRejected(IdeaEntity idea, String rejectionComment, String campaignTitle); void notifyCreatorAndAdminOnProjectModification(ProjectEntity project, UserEntity modifier); void notifyAdminOnProjectCreation(ProjectEntity project, String emailAddress); void notifyAdminOnIdeaCreation(IdeaEntity idea, String emailAddress, String campaignTitle); static final Integer COMMENT_EXCERPT_LENGTH; static final String FROM_ADDRESS; static final String PROJECT_LINK_PATTERN; static final String ACTIVATION_LINK_PATTERN; static final String PASSWORD_RECOVERY_LINK_PATTERN; static final String IDEA_CAMPAIGN_LINK_PATTERN; static final String IDEA_CAMPAIGN_LINK_ADMIN_PATTERN; static final String IDEA_CAMPAIGN_YOUR_IDEAS_LINK_PATTERN; static final String SUBJECT_ACTIVATION; static final String SUBJECT_PASSWORD_FORGOTTEN; static final String SUBJECT_IDEA_CREATED; static final String SUBJECT_IDEA_ACCEPTED; static final String SUBJECT_IDEA_REJECTED; static final String SUBJECT_PROJECT_MODIFIED; static final String SUBJECT_PROJECT_CREATED; static final String SUBJECT_PROJECT_PUBLISHED; static final String SUBJECT_PROJECT_REJECTED; static final String SUBJECT_PROJECT_DEFERRED; static final String SUBJECT_PROJECT_COMMENTED; }
@Test public void testSendActivationMail() { UserEntity user = aProjectCreator(); user.setActivationToken("activationTok3n"); userNotificationService.sendActivationMail(user); SimpleMailMessage mail = getMessageFromMailSender(); assertThat(mail.getFrom(), is(UserNotificationService.FROM_ADDRESS)); assertThat(mail.getTo(), arrayContaining(user.getEmail())); assertThat(mail.getSubject(), is(UserNotificationService.SUBJECT_ACTIVATION)); assertThat(replaceLineBreaksIfWindows(mail.getText()), is( "Hallo Guybrush,\n\n" + "Du hast Dich gerade auf der CrowdSource Platform angemeldet.\n" + "Um Deine Registrierung abzuschließen, öffne bitte diesen Link und setze Dein Passwort:\n\n" + "https: "Mit freundlichen Grüßen\nDein CrowdSource Team")); }