UserNotificationService { public void notifyAdminOnProjectCreation(ProjectEntity project, String emailAddress) { final String projectLink = buildProjectLink(project.getId()); StandardEvaluationContext context = new StandardEvaluationContext(); context.setVariable("link", projectLink); final String mailContent = newProjectEmailTemplate.getValue(context, String.class); sendMail(emailAddress, SUBJECT_PROJECT_CREATED, 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 testNotifyAdminOnProjectCreation() { UserEntity user = aProjectCreator(); userNotificationService.notifyAdminOnProjectCreation(project("proj3ctId", ProjectStatus.PUBLISHED, user, "My Super Project"), ADMIN_EMAIL); SimpleMailMessage mail = getMessageFromMailSender(); assertThat(mail.getFrom(), is(UserNotificationService.FROM_ADDRESS)); assertThat(mail.getTo(), arrayContaining(ADMIN_EMAIL)); assertThat(mail.getSubject(), is(UserNotificationService.SUBJECT_PROJECT_CREATED)); assertThat(replaceLineBreaksIfWindows(mail.getText()), is( "Hallo Admin,\n\n" + "es liegt ein neues Projekt zur Freigabe vor:\n\n" + "https: "Mit freundlichen Grüßen\n" + "Dein CrowdSource Team")); }